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?
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.]
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.
Re: Memory Leak? GarbageCollector Gen0 Objects are only increasing
Is the memory being retained even needed?
Re: Memory Leak? GarbageCollector Gen0 Objects are only increasing
Started me humming a song by the Who. My g-g-g-generation!
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.
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!