[commit] r2629 - in trunk: GME/Core Tests/GPyUnit Tests/GPyUnit/Leaks/TestGMELeaks

GMESRC Repository Notifications gme-commit at list.isis.vanderbilt.edu
Fri Apr 15 17:36:10 CDT 2016


Author: ksmyth
Date: Fri Apr 15 17:36:10 2016
New Revision: 2629

Log:
Fix memory leak on DestroyObject

Modified:
   trunk/GME/Core/CoreAttribute.cpp
   trunk/GME/Core/CoreObject.cpp
   trunk/GME/Core/CoreObject.h
   trunk/Tests/GPyUnit/Leaks/TestGMELeaks/TestGMELeaks.cpp
   trunk/Tests/GPyUnit/test_leaks.py

Modified: trunk/GME/Core/CoreAttribute.cpp
==============================================================================
--- trunk/GME/Core/CoreAttribute.cpp	Fri Apr 15 17:36:06 2016	(r2628)
+++ trunk/GME/Core/CoreAttribute.cpp	Fri Apr 15 17:36:10 2016	(r2629)
@@ -319,12 +319,16 @@
 			Unload();
 			return S_OK;
 		}
+		locking_type oldVal = 0;
+		if (locking == PUT_DELETE_DONE_LOCK) {
+			locking = LOCKING_NONE;
+			oldVal = LOCKING_EXCLUSIVE;
+		}
 
 		if( !(LOCKING_NONE <= locking && locking <= LOCKING_EXCLUSIVE) )
 			HR_THROW(E_INVALIDARG);
 
-		// FIXME: 0 is not right, does it matter?
-		RegisterLockTry(0, locking );
+		RegisterLockTry(oldVal, locking);
 	}
 	COMCATCH(;)
 }

Modified: trunk/GME/Core/CoreObject.cpp
==============================================================================
--- trunk/GME/Core/CoreObject.cpp	Fri Apr 15 17:36:06 2016	(r2628)
+++ trunk/GME/Core/CoreObject.cpp	Fri Apr 15 17:36:10 2016	(r2629)
@@ -314,7 +314,7 @@
 			++i;
 		}
 
-		COMTHROW( lock->put_Value(PutInVariant(locking_type(LOCKING_NONE))) );
+		COMTHROW( lock->put_Value(PutInVariant(locking_type(PUT_DELETE_DONE_LOCK))) );
 	}
 	COMCATCH(;)
 }

Modified: trunk/GME/Core/CoreObject.h
==============================================================================
--- trunk/GME/Core/CoreObject.h	Fri Apr 15 17:36:06 2016	(r2628)
+++ trunk/GME/Core/CoreObject.h	Fri Apr 15 17:36:10 2016	(r2629)
@@ -8,6 +8,8 @@
 #include <list>
 //#include <slist>
 
+const locking_type PUT_DELETE_DONE_LOCK = 55;
+
 class CCoreProject;
 class CCoreAttribute;
 class CCoreLockAttribute;

Modified: trunk/Tests/GPyUnit/Leaks/TestGMELeaks/TestGMELeaks.cpp
==============================================================================
--- trunk/Tests/GPyUnit/Leaks/TestGMELeaks/TestGMELeaks.cpp	Fri Apr 15 17:36:06 2016	(r2628)
+++ trunk/Tests/GPyUnit/Leaks/TestGMELeaks/TestGMELeaks.cpp	Fri Apr 15 17:36:10 2016	(r2629)
@@ -46,6 +46,20 @@
 			project->OpenEx(_bstr_t("MGA=") + _bstr_t(gme_root) + L"\\Paradigms\\MetaGME\\MetaGME-model.mga", _bstr_t("MetaGME"), _variant_t());
 			project->BeginTransactionInNewTerr(TRANSACTION_GENERAL);
 			project->CommitTransaction();
+
+			project->BeginTransactionInNewTerr(TRANSACTION_GENERAL);
+			auto aspects = project->ObjectByPath[L"/@Aspects"];
+			IMgaFCOPtr aspectsFco = aspects;
+			auto copy = aspectsFco->ParentFolder->CopyFCODisp(aspectsFco);
+			copy->DestroyObject();
+
+			project->CommitTransaction();
+			project->Undo();
+			project->Redo();
+			project->Undo();
+			project->FlushUndoQueue();
+
+
 			project->Close(VARIANT_TRUE);
 		}
 		catch (_com_error& e)
@@ -61,10 +75,11 @@
 		}
 	}
 
-	CoFreeUnusedLibraries();
-	CoUninitialize();
 	wprintf(L"%S finished\n", argv[0]);
 	while (fgetc(stdin) != '\n')
 		;
+
+	CoFreeUnusedLibraries();
+	CoUninitialize();
 	return 0;
 }

Modified: trunk/Tests/GPyUnit/test_leaks.py
==============================================================================
--- trunk/Tests/GPyUnit/test_leaks.py	Fri Apr 15 17:36:06 2016	(r2628)
+++ trunk/Tests/GPyUnit/test_leaks.py	Fri Apr 15 17:36:10 2016	(r2629)
@@ -1,5 +1,6 @@
 import unittest
 import os
+import re
 
 def _adjacent_file(file):
     import os.path
@@ -17,13 +18,15 @@
                 print stdout
                 print stderr
                 raise subprocess.CalledProcessError(sub.returncode, args[0])
-        check_output_if_failed([r'c:\Windows\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe', 
+        check_output_if_failed([r'c:\Windows\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe',
             _adjacent_file(r'Leaks\TestGMELeaks\TestGMELeaks.vcxproj'), '/p:Configuration=Release'])
         check_output_if_failed([r'\Program Files (x86)\Debugging Tools for Windows (x86)\gflags.exe'] +
             '-i TestGMELeaks.exe +ust'.split())
         umdh = r"c:\Program Files (x86)\Debugging Tools for Windows (x86)\umdh.exe"
-        
+
         os.environ['OANOCACHE'] = '1'
+        os.environ['_NT_SYMBOL_PATH'] = r'c:\Windows\symbols\dll;srv*c:\symbols*https://msdl.microsoft.com/download/symbols'
+
         leak_sub = subprocess.Popen([_adjacent_file(r'Leaks\TestGMELeaks\Release\TestGMELeaks.exe')], stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
         print leak_sub.stdout.readline()
         check_output_if_failed([umdh] + '-pn:TestGMELeaks.exe -f:LeakDump1.txt'.split())
@@ -37,9 +40,12 @@
 
         leak_sub.wait()
         self.assertEqual(0, leak_sub.returncode)
-        
+
         lines = open('LeakDiff.txt', 'rb').readlines()
-        self.assertTrue([line for line in lines[-3:] if line.find('Total decrease ==')], lines[-3:])
-        
+        # Total decrease ==      0 requested +      0 overhead =      0
+        self.assertTrue([line for line in lines[-3:] if line.find('Total decrease ==') != -1], lines[-3:])
+
+        # self.assertEqual([], [line for line in lines if re.search('(MSVCR\\d+!malloc\\+|MSVCR\\d+!operator new)', line)])
+
 if __name__ == "__main__":
         unittest.main()


More information about the gme-commit mailing list