Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why do I appear to have a memory leak when user "Server" garbage collection?

Here's my situation. I want an explanation of why this is happening. I am reading about GC here but I still don't get it.

Workstation case: When I run with workstation garbage collection, my app ramps up to use about 180MB of private bytes and about 70MB in ".NET CLR Memory #bytes in all heaps". Memory continues to be stable for several hours. Life is good.

Server case: When I run with server garbage collection my app ramps up to use about 500MB of private bytes but still only about 70MB in ".NET CLR Memory #bytes in all heaps". An analysis of the !DumpHeap -stat output and !GCRoot shows a lot of objects without roots. Also, my private bytes increase significantly over several hours but the .NET bytes remain constant. My app DOES use a lot of unmanaged code so I'm thinking this is related given the difference in private and .NET bytes. But why is my life so bad in the server case?

Any GC wisdom or guidance on further investigation?

Thanks!

like image 883
noctonura Avatar asked Feb 23 '10 22:02

noctonura


People also ask

What is memory leaks in garbage collector?

A Memory Leak is a situation where there are objects present in the heap that are no longer used, but the garbage collector is unable to remove them from memory, and therefore, they're unnecessarily maintained. A memory leak is bad because it blocks memory resources and degrades system performance over time.

Does garbage collection prevent memory leaks?

Although garbage collection prevents many types of memory leaks, it doesn't prevent all of them. In automatic reference counting systems, such as Perl or Objective-C, memory is leaked whenever there are cyclical references, since the reference count is never decremented to zero.

What could be the possible cause of memory leaks?

In computer science, a memory leak is a type of resource leak that occurs when a computer program incorrectly manages memory allocations in a way that memory which is no longer needed is not released. A memory leak may also happen when an object is stored in memory but cannot be accessed by the running code.

Does garbage collection use memory?

The garbage collector provides the following benefits: Frees developers from having to manually release memory. Allocates objects on the managed heap efficiently. Reclaims objects that are no longer being used, clears their memory, and keeps the memory available for future allocations.


1 Answers

"Server garbage collection" is designed for high-throughput applications, primarily on clustered servers.

A server GC is expensive, and suspends running threads while it happens. As such, it takes a lot more memory pressure before it actually triggers - if you've still got spare memory, don't be surprised if the garbage collector doesn't feel the need to go through and clean up yet.

like image 56
Anon. Avatar answered Sep 22 '22 16:09

Anon.