Memory leak in MultiThread

Please don't post Bullet support questions here, use the above forums instead.
Post Reply
nsdavidlj
Posts: 10
Joined: Mon Oct 26, 2009 3:40 pm

Memory leak in MultiThread

Post by nsdavidlj »

I have use multi-thread collision . coding like MultiThreadedDemo.
but msvc (or VLD) can detect some memory leaks in MultiThreaded mode.
I also tested MultiThreadedDemo with VLD.but leak detected much more.

here is the leak log in my project:

WARNING: Visual Leak Detector detected memory leaks!
---------- Block 36 at 0x01F7EAB8: 91 bytes ----------
Call Stack:
c:\developer\support\bullet-2.78\src\linearmath\btalignedallocator.cpp (24): MyBullet.dll!btAllocDefault + 0xC bytes
c:\developer\support\bullet-2.78\src\linearmath\btalignedallocator.cpp (67): MyBullet.dll!btAlignedAllocDefault + 0x13 bytes
c:\developer\support\bullet-2.78\src\linearmath\btalignedallocator.cpp (164): MyBullet.dll!btAlignedAllocInternal + 0x10 bytes
c:\developer\support\bullet-2.78\src\bulletmultithreaded\win32threadsupport.cpp (429): MyBullet.dll!Win32ThreadSupport::createBarrier + 0x9 bytes
c:\developer\support\bullet-2.78\src\bulletmultithreaded\btparallelconstraintsolver.cpp (995): MyBullet.dll!btParallelConstraintSolver::btParallelConstraintSolver + 0x19 bytes
Data:
CD CD CD CD B8 EA F7 01 B0 BF C9 03 58 C7 2C 00 ........ ....X.,.
FF FF FF FF 00 00 00 00 00 00 00 00 00 00 00 00 ........ ........
00 00 00 00 F8 A4 ED 07 FF FF FF FF 00 00 00 00 ........ ........
00 00 00 00 00 00 00 00 00 00 00 00 FC 01 00 00 ........ ........
00 02 00 00 00 00 00 00 00 00 00 00 02 00 00 00 ........ ........
CD CD CD CD CD CD CD CD CD CD CD ........ ........


---------- Block 37 at 0x08CE12A8: 195 bytes ----------
Call Stack:
c:\developer\support\bullet-2.78\src\linearmath\btalignedallocator.cpp (24): MyBullet.dll!btAllocDefault + 0xC bytes
c:\developer\support\bullet-2.78\src\linearmath\btalignedallocator.cpp (67): MyBullet.dll!btAlignedAllocDefault + 0x13 bytes
c:\developer\support\bullet-2.78\src\linearmath\btalignedallocator.cpp (164): MyBullet.dll!btAlignedAllocInternal + 0x10 bytes
c:\developer\support\bullet-2.78\src\bulletmultithreaded\win32threadsupport.cpp (437): MyBullet.dll!Win32ThreadSupport::createCriticalSection + 0xC bytes
c:\developer\support\bullet-2.78\src\bulletmultithreaded\btparallelconstraintsolver.cpp (996): MyBullet.dll!btParallelConstraintSolver::btParallelConstraintSolver + 0x19 bytes
Data:
CD CD CD CD A8 12 CE 08 D8 BF C9 03 CD CD CD CD ........ ........
CD CD CD CD CD CD CD CD CD CD CD CD CD CD CD CD ........ ........
CD CD CD CD CD CD CD CD CD CD CD CD CD CD CD CD ........ ........
CD CD CD CD CD CD CD CD CD CD CD CD CD CD CD CD ........ ........
CD CD CD CD CD CD CD CD CD CD CD CD CD CD CD CD ........ ........
CD CD CD CD CD CD CD CD CD CD CD CD CD CD CD CD ........ ........
CD CD CD CD CD CD CD CD CD CD CD CD CD CD CD CD ........ ........
CD CD CD CD CD CD CD CD CD CD CD CD CD CD CD CD ........ ........
CD CD CD CD CD CD CD CD CD CD CD CD CD CD CD CD ........ ........
CD CD CD CD CD CD CD CD 30 A5 ED 07 FF FF FF FF ........ 0.......
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ........ ........
CD CD CD CD CD CD CD CD CD CD CD CD CD CD CD CD ........ ........
CD CD CD ........ ........


---------- Block 28 at 0x08D4D190: 23168 bytes ----------
Call Stack:
f:\vs70builds\3077\vc\crtbld\crt\src\newop.cpp (12): MyBullet.dll!operator new + 0x9 bytes
c:\developer\support\bullet-2.78\src\bulletmultithreaded\spunarrowphasecollisiontask\spugatheringcollisiontask.cpp (196): MyBullet.dll!createCollisionLocalStoreMemory + 0xA bytes
c:\developer\support\bullet-2.78\src\bulletmultithreaded\win32threadsupport.cpp (268): MyBullet.dll!Win32ThreadSupport::startThreads + 0x8 bytes
c:\developer\support\bullet-2.78\src\bulletmultithreaded\win32threadsupport.cpp (37): MyBullet.dll!Win32ThreadSupport::Win32ThreadSupport

00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ........ ........
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ........ ........
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ........ ........
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ........ ........
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ........ ........
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ........ ........
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ........ ........
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ........ ........
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ........ ........
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ........ ........
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ........ ........
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ........ ........
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ........ ........
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ........ ........
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ........ ........
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ........ ........


---------- Block 29 at 0x08D52C50: 23168 bytes ----------
Call Stack:
f:\vs70builds\3077\vc\crtbld\crt\src\newop.cpp (12): MyBullet.dll!operator new + 0x9 bytes
c:\developer\support\bullet-2.78\src\bulletmultithreaded\spunarrowphasecollisiontask\spugatheringcollisiontask.cpp (196): MyBullet.dll!createCollisionLocalStoreMemory + 0xA bytes
c:\developer\support\bullet-2.78\src\bulletmultithreaded\win32threadsupport.cpp (268): MyBullet.dll!Win32ThreadSupport::startThreads + 0x8 bytes
c:\developer\support\bullet-2.78\src\bulletmultithreaded\win32threadsupport.cpp (37): MyBullet.dll!Win32ThreadSupport::Win32ThreadSupport

Data:
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ........ ........
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ........ ........
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ........ ........
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ........ ........
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ........ ........
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ........ ........
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ........ ........
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ........ ........
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ........ ........
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ........ ........
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ........ ........
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ........ ........
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ........ ........
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ........ ........
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ........ ........
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ........ ........


Visual Leak Detector detected 4 memory leaks.
Visual Leak Detector is now exiting.
Detected memory leaks!
Dumping objects ->
{7019} normal block at 0x08CE12A8, 195 bytes long.
Data: < > CD CD CD CD A8 12 CE 08 D8 BF C9 03 CD CD CD CD
{7018} normal block at 0x01F7EAB8, 91 bytes long.
Data: < X , > CD CD CD CD B8 EA F7 01 B0 BF C9 03 58 C7 2C 00
{7008} normal block at 0x08D52C50, 23168 bytes long.
Data: < > 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
{7007} normal block at 0x08D4D190, 23168 bytes long.
Data: < > 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
Object dump complete.
zerochen
Posts: 4
Joined: Fri Jun 01, 2012 3:21 pm

Re: Memory leak in MultiThread

Post by zerochen »

hi

yes i think your are right i found it too.

here is the patch to solve it. not sure whether its right or not but it works. maybe someone can confirm this?

Code: Select all

Index: btParallelConstraintSolver.cpp
===================================================================
--- btParallelConstraintSolver.cpp (Revision 2538)
+++ btParallelConstraintSolver.cpp (Arbeitskopie)
@@ -1002,6 +1002,8 @@
{
delete m_memoryCache;
delete m_solverIO;
+ delete m_barrier;
+ delete m_criticalSection;
}


Index: PosixThreadSupport.cpp
===================================================================
--- PosixThreadSupport.cpp (Revision 2538)
+++ PosixThreadSupport.cpp (Arbeitskopie)
@@ -248,6 +248,9 @@
destroySem(spuStatus.startSemaphore);
printf("semaphore destroyed\n");
checkPThreadFunction(pthread_join(spuStatus.thread,0));
+
+ if(spuStatus.m_lsMemory)
+ delete spuStatus.m_lsMemory;
}
printf("destroy main semaphore\n");
destroySem(mainSemaphore);
Index: Win32ThreadSupport.cpp
===================================================================
--- Win32ThreadSupport.cpp (Revision 2538)
+++ Win32ThreadSupport.cpp (Arbeitskopie)
@@ -299,6 +299,9 @@
CloseHandle(spuStatus.m_eventCompletetHandle);
CloseHandle(spuStatus.m_eventStartHandle);
CloseHandle(spuStatus.m_threadHandle);
+
+ if(spuStatus.m_lsMemory)
+ delete spuStatus.m_lsMemory;
}

m_activeSpuStatus.clear();


Post Reply