Results 1 to 6 of 6

Thread: my threading causes memory leaks?

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Mar 2002
    Location
    trinsic
    Posts
    21

    my threading causes memory leaks?

    well.. hmm.. seems that my program take up about 10 meg ram runnin.. but when i start the threading part.. it jumps to 35..
    ok.. so fine.. but when i close that form... (its a different form than the main) the memory is never free'd up.. and i know all the threads exited.. cause it outputs on the console... .. i have it testing in the procedure that the thread runs. for a variable.. and if it see's it. it exits the sub...
    and when i reopen that form. it eats up 10-15 more megs.. and so on and so on..
    question is
    how are you possed to stop threads? or. how do you free the ram the threads were runnin on.
    thanks

    karthic

  2. #2

    Thread Starter
    Junior Member
    Join Date
    Mar 2002
    Location
    trinsic
    Posts
    21

    FORGOT TO MENTION

    and when i exit the program.. it actually doesnt close the way.. the form closes.. but its still in memory. till i end it..
    thanks
    ------------------------------------------------------------------

    ignore this reply... i found that mistake.. i had a never ending do loop.. but still takes up 35 megs ram till the program completly closes.. and continully takes more.. if i close and reopen that window...
    karthic
    Last edited by karthic; Apr 16th, 2002 at 07:36 AM.

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Mar 2002
    Location
    trinsic
    Posts
    21

    hmm ok. its like this

    well.. ok.. its like this.. my program creates threads.. and then they die.. doesnt keep track of em
    just create em and die.. and every time start and stop that part of it.. it constantly adds 15 more megs ram to my process used.. anyone know?
    thanks

  4. #4
    old fart Frans C's Avatar
    Join Date
    Oct 1999
    Location
    the Netherlands
    Posts
    2,926
    Although it may look like a memory leak, it probably isn't.
    Assuming you use managed code (API's can still cause memory and other leaks) the garbage collector will do its work.
    But, you can't say when the garbage collector will free the memory. As soon as memory will become scarce, the garbage collector will jump in, but as long as there is enough memory available, the garbage collector can take it's time before it does it's job.

    To force garbage collection at specific moment you can use System.GC.Collect, but it shouldn't be necessary.

    In short: as long as you use managed code, you should not need to worry about memory leaks.

  5. #5

    Thread Starter
    Junior Member
    Join Date
    Mar 2002
    Location
    trinsic
    Posts
    21

    managed code?

    managed code?
    i'm sorry.. can you explain or direct me to where managed code is explained?
    thanks

  6. #6
    old fart Frans C's Avatar
    Join Date
    Oct 1999
    Location
    the Netherlands
    Posts
    2,926
    Some places to look in the VS.NET help file:

    Overview of the .NET framework
    ms-help://MS.VSCC/MS.MSDNVS/cpguide/html/cpovrintroductiontonetframeworksdk.htm

    GC Class
    ms-help://MS.VSCC/MS.MSDNVS/cpref/html/frlrfSystemGCClassTopic.htm

    And another one:
    Automatic Memory Management
    ms-help://MS.VSCC/MS.MSDNVS/cpguide/html/cpconautomaticmemorymanagement.htm

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width