[mapguide-internals] Memory leakage in WebTier (Java)

Andreas Morf a.morf at fkl.ch
Wed Sep 1 09:12:05 EDT 2010


Hi all
I'm intensively using the java webtier and with more users accessing mapguide this is getting a real problem:

After every call to a servlet using MgApi the memory consumption of javaw.exe (tomcat) is increasing even after GC. I used a memory
profiler on javaw and saw that almost all the MgXXX objects remain in memory.
After some more investigations with the debugger I remarked the following pattern which I can describe on an example:

...
MgByteSource src = new MgByteSource(b, b.length);
MgByteReader layerDefContent = src.GetReader();
...

When gc deletes the src-object the MgGuardDisposable::Release() is called by JNI. Because of the 'src.GetReader()' call m_refCount
has a value of 2, so 'Release()' just decreases it by 1 and returns to JAVA without calling the Dispose() method of MgByteSource. So
the java-object is deleted while the C++ object remains orphaned in memory.
This pattern is happening with almost every MgApi usage and my LoadMap-Servlet which creates a new MgMap and saves all Layers with a
filter to the Session-Repository every run leads to a leakage of around 5MB (MgMap has quite a large cascade of (not just small)
child objects).

Can anyone confirm my diagnosis and maybe give a hint where/how to fix this problem and is this maybe a general memory management
issue?

Greets, Andreas




More information about the mapguide-internals mailing list