learning sites for fixing java memory leaks

橙三吉。 提交于 2019-12-05 19:08:28

Have you tried searching the internet? There are many examples. A good search engine will sort them by relevance.

There are many kind of memory leaks but in practice the following strategy gives good results (Disclaimer: I'm showing screen shots from JProfiler, because my company develops it):

1. Check the biggest objects

"Biggest objects" retain a lot of memory that nobody else is holding on to. In JProfiler, they can be found in the "Biggest objects" view of the heap walker. This often happens with caches.

2. Check classes with a lot of instances

Sometimes, the references are more intricate and the biggest objects do not give a clue. Classes with a lot of instances can be checked for their incoming references. First, it is helpful to look at cumulated references, to separate valid reference chains from suspicious reference chains.

Also, checking where instances have been allocated (as opposed to how they are referenced) can often give an insight on what is going on.

Often, this is a multi-step process, selecting reference chains, allocation spots, or making selections based on the contents of objects.

3. Search for paths to GC roots

If that still does not provide a clue, you can select single objects and show their reference chains that lead to garbage collector roots. It helps a lot of you were able to narrow down an object set of suspicious objects before trying to to that, otherwise you may have a lot of candidates.

There is also a screen cast on this topic.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!