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

Bruce Dechant bruce.dechant at autodesk.com
Wed Sep 1 12:00:08 EDT 2010


Andreas,

What version of Tomcat are you using? 
I ask because there is a known Tomcat issue with memory leak prevention not being enabled by default.

Regardless, please check that the following entry is in the Tomcat server.xml file. This entry fixes lots of Java memory leaks.

  <!-- Prevent memory leaks due to use of particular java/javax APIs-->
  <Listener className="org.apache.catalina.core.JreMemoryLeakPreventionListener" />

Thanks,
Bruce


-----Original Message-----
From: mapguide-internals-bounces at lists.osgeo.org [mailto:mapguide-internals-bounces at lists.osgeo.org] On Behalf Of Andreas Morf
Sent: Wednesday, September 01, 2010 7:12 AM
To: mapguide-internals at lists.osgeo.org
Subject: [mapguide-internals] Memory leakage in WebTier (Java)

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


_______________________________________________
mapguide-internals mailing list
mapguide-internals at lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/mapguide-internals


More information about the mapguide-internals mailing list