Bug #65874 java memory leak SessionFactory.getSession()
Submitted: 11 Jul 2012 16:43 Modified: 4 Oct 2013 23:53
Reporter: Alex Constantinescu Email Updates:
Status: Not a Bug Impact on me:
None 
Category:MySQL Cluster: Cluster/J Severity:S1 (Critical)
Version:7.2.14 OS:Any
Assigned to: CPU Architecture:Any

[11 Jul 2012 16:43] Alex Constantinescu
Description:
In a Linux (Ubuntu) if you create and close 1 million sessions, the non-heap memory of java it will grow indefinitely. You can see if you execute the program below, run in another console "top" program and watch the "RES" field.

How to repeat:
SessionFactory factory = ClusterJHelper.getSessionFactory(props);

for (int i=0;i<1000000;i++){
  Session session = factory.getSession();
  session.currentTransaction().begin(); 
  session.currentTransaction().commit() ;
  close(); 
}

Suggested fix:
From what I debugged the problem seems to be related with creation of the DbImpl.
[22 Jul 2013 20:58] Sveta Smirnova
Thank you for the report.

Verified as described.
[10 Sep 2013 0:16] Craig Russell
The system appears to work correctly. The DBImpl objects are subject to garbage collection and when System.gc() is run explicitly (or the garbage collector runs at intervals determined by the rest of the system) the DBImpl objects no longer referenced by clusterj Session objects are collected.

If the heap is so large that the garbage collector never kicks in during your test, try an explicit System.gc() every 100000 iterations or so.