[mapguide-commits] r6611 - in trunk/MgDev/Oem/SWIGEx: Source/Modules Win32

svn_mapguide at osgeo.org svn_mapguide at osgeo.org
Thu May 3 22:39:37 EDT 2012


Author: hubu
Date: 2012-05-03 19:39:37 -0700 (Thu, 03 May 2012)
New Revision: 6611

Modified:
   trunk/MgDev/Oem/SWIGEx/Source/Modules/java.cxx
   trunk/MgDev/Oem/SWIGEx/Win32/Swig.exe
Log:
On behalf of Andy Zhang.
Fix ticket #1960 in trunk: ByteSource and ByteReader memory leak in Java Api

The generated Java method MgByteSource::GetReader() is like below:
public MgByteReader GetReader() throws MgException  {
    long cPtr = MapGuideJavaApiJNI.MgByteSource_GetReader(swigCPtr);
    return (cPtr == 0) ? null : (MgByteReader)ObjectFactory.createObject(MapGuideJavaApiJNI.getClassId(cPtr), cPtr, false);
  }

The last parameter indicated whether the object owns memory itself. In Java API, it is always false. That means it will not call MapGuideJavaApiJNI.delete_MgByteReader(swigCPtr) when deleting the object, which results in memory leak.

Now change the last parameter to 'true' to fix this issue. The change is consistant with CSharp.

Modified: trunk/MgDev/Oem/SWIGEx/Source/Modules/java.cxx
===================================================================
--- trunk/MgDev/Oem/SWIGEx/Source/Modules/java.cxx	2012-05-04 02:37:39 UTC (rev 6610)
+++ trunk/MgDev/Oem/SWIGEx/Source/Modules/java.cxx	2012-05-04 02:39:37 UTC (rev 6611)
@@ -2000,7 +2000,7 @@
       addThrows(n, "tmap:javaout", n);
 	  if(returnObject)
 	  {
-		  Replaceall(tm, "new $javaclassname(cPtr, $owner)", "($javaclassname)ObjectFactory.createObject($module.getClassId(cPtr), cPtr, $owner)");
+		  Replaceall(tm, "new $javaclassname(cPtr, $owner)", "($javaclassname)ObjectFactory.createObject($module.getClassId(cPtr), cPtr, true)");
 		  Replaceall(tm, "$module", imclass_name);
 	  }
       if (Getattr(n,"feature:new"))

Modified: trunk/MgDev/Oem/SWIGEx/Win32/Swig.exe
===================================================================
(Binary files differ)



More information about the mapguide-commits mailing list