Results 1 to 7 of 7

Thread: Memory Leak? GarbageCollector Gen0 Objects are only increasing

  1. #1

    Thread Starter
    I don't do your homework! opus's Avatar
    Join Date
    Jun 2000
    Location
    Good Old Europe
    Posts
    3,863

    Memory Leak? GarbageCollector Gen0 Objects are only increasing

    In my application the number of GC Gen0 objects is constantly increasing, nearly none are moved to Gen1 nor are any released by explicitly calling GC.collect.
    Where/How could I look for the cause?
    You're welcome to rate this post!
    If your problem is solved, please use the Mark thread as resolved button


    Wait, I'm too old to hurry!

  2. #2
    PowerPoster Evil_Giraffe's Avatar
    Join Date
    Aug 2002
    Location
    Suffolk, UK
    Posts
    2,555

    Re: Memory Leak? GarbageCollector Gen0 Objects are only increasing

    Don't look for the cause, you shouldn't be forcing a garbage collection in your situation. As I told you in your other thread, the system isn't reclaiming the memory because there is no pressure to do so, nothing else needs the resources. This is the point of a managed memory environment.

    [Edit: Also, if the objects stay in Gen0 after calling GC.Collect then you're doing something wrong. Any object that survives a collection of its generation gets promoted, so if all your objects are still in Gen0 then you've not done a collection. They will either be reclaimed or promoted to Gen1.]

  3. #3
    PowerPoster
    Join Date
    Mar 2002
    Location
    UK
    Posts
    4,780

    Re: Memory Leak? GarbageCollector Gen0 Objects are only increasing

    Use a memory profiler to see what types of objects there are, and what is keeping them open. There is one I believe in VS2012 (I have not used it), or buy/find an external one. In the past I have used one such as redgates.

    I have found the simple way to find leaks (if this is what you actually have, after reading evil's post), is to take a snapshot after loading everything once, open/process again and take another snapshot and compare the deltas, if your app is growing, it will the because of the class with the highest unexpected delta change.
    Last edited by Grimfort; Jul 8th, 2013 at 02:01 PM.

  4. #4
    Bad man! ident's Avatar
    Join Date
    Mar 2009
    Location
    Cambridge
    Posts
    5,401

    Re: Memory Leak? GarbageCollector Gen0 Objects are only increasing

    Is the memory being retained even needed?
    My Github - 1d3nt

  5. #5
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    40,109

    Re: Memory Leak? GarbageCollector Gen0 Objects are only increasing

    Started me humming a song by the Who. My g-g-g-generation!
    My usual boring signature: Nothing

  6. #6
    Bad man! ident's Avatar
    Join Date
    Mar 2009
    Location
    Cambridge
    Posts
    5,401

    Re: Memory Leak? GarbageCollector Gen0 Objects are only increasing

    You do realize running the GC has alot of costs. Well some. Do you have any free memory left? It's better for the process to ask for more memory then clean up all your objects. Asking for more memory is cheaper. Obviously if there is no more memory then we have to call the GC. In actual fact i guess it could be an allocation choice issue.
    My Github - 1d3nt

  7. #7

    Thread Starter
    I don't do your homework! opus's Avatar
    Join Date
    Jun 2000
    Location
    Good Old Europe
    Posts
    3,863

    Re: Memory Leak? GarbageCollector Gen0 Objects are only increasing

    I using the .collect just for TESTING, and I´m doing this test just because I saw this weird numbers Gen0 increases constatly (by roughly 125 per sec or iteration) Gen1 increases only by 1 every 10secs and Gen2 increases by 1 every minute.
    Evil_Giraffe, I DID listen to you!
    You're welcome to rate this post!
    If your problem is solved, please use the Mark thread as resolved button


    Wait, I'm too old to hurry!

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