Challenge:
Before couple of weeks, we wanted to check whether our application has memory leaks issue or not? And while doing that we found few articles, understood something, and learnt something which I would like to share with you.
Solution:
Best links to read:
http://www.codeproject.com/Articles/42721/Best-Practices-No-5-Detecting-NET-application-memo
http://blogs.msdn.com/b/tess/archive/2005/11/25/496899.aspx
Basically, to detect Memory leak you should check following things:
You should check if Private Bytes/Bytes in all heaps/Virtual bytes increase at the same rate. If you don’t see growing of private bytes, so it means no any memory leak is happening!
Expert comments from Ekaterina — Genius person on this earth who helped us to understand this issue (God bless Ekaterina and Tess!):
Generation 0:
This counter displays the number of times the generation 0 objects (youngest; most recently allocated) are garbage collected (Gen 0 GC) since the start of the application.So when this number becomes higher over the time, it is OK. It just should grow at steady pace.
if you create a simple program, that will create in cycle a lot of large objects and put them to some archive (this will be not really a memory leak however you’ll get an OOM). In this case private bytes and bytes in all heaps will grow at the
same rate, and this can be treated as excessive memory consuming in managed code.
Also I noticed that when you have this memory problem, number of GC collection is also jumping and growing high very quickly – because new large portions of memory should be allocated fast, so I also pay attention to GC behavior.
Happy Coding! 🙂
[…] Basics of Memory leak […]
[…] %Time in GC — When this time is high, your requests will get paused for a while and your end users will see slow response time during this time. If it is >=10% then you need to dig in to this issue. Also, check for Memory Leak — http://kiranpatils.wordpress.com/2012/06/05/basics-of-memory-leak/ […]