As I've found somewhere on web, following items can lead to memory leaks. For example:
- ResultSets and Statement objects
- DataLists
- Collections
- Static variables and classes
- Singletons
- HttpSession and HttpRequest
Managed beans in my JSF application are mostly @ViewScoped
, so I thought that after leaving the view, GC has enough informations to release datalists, objects, and so on. But it hasn't or not completelly:
I'm just closing hibernate sessions manually (using finally), but that's all. The rest of things I've expected from GC.
Could you tell me,
- how to find which concrete objects are staying in memory?
- how to release objects after leaving a view manually? something like destructor..?
- what are the best practices in handle memory leaks?