Page 1 of 1

Memory leaking in Visual Studio 11

Posted: Thu Mar 29, 2012 5:26 am
by reinux
I compiled Bullet 2.8 in the Visual Studio 11 on the Windows 8 beta, and I'm noticing strange memory leaks when I #include btBulletDynamics.h.

Normally I'd just blame VC++11 considering it's in beta, but it doesn't seem to leak with any of my other code, so I'm beginning to suspect if maybe it's something in Bullet that might eventually need a fix.

I tried the Hello World program verbatim, and it gives me a bunch of leaks:

Code: Select all

Detected memory leaks!
Dumping objects ->
{106} normal block at 0x010EBD00, 36 bytes long.
 Data: <  6        ;M   > 20 EC 36 01 01 00 00 00 A6 9B C4 3B 4D 00 00 00 
{105} normal block at 0x010EBCA0, 36 bytes long.
 Data: <x 6     o  :L   > 78 EC 36 01 01 00 00 00 6F 12 83 3A 4C 00 00 00 
{104} normal block at 0x010EBC40, 36 bytes long.
 Data: <h 6     o  :K   > 68 EC 36 01 01 00 00 00 6F 12 83 3A 4B 00 00 00 
{103} normal block at 0x010EBBE0, 36 bytes long.
 Data: <  6     B` ;D   > C0 EC 36 01 01 00 00 00 42 60 E5 3B 44 00 00 00 
{102} normal block at 0x010EBB80, 36 bytes long.
 Data: <  6       D<6   > B8 F4 36 01 01 00 00 00 A6 9B 44 3C 36 00 00 00 
{101} normal block at 0x010EBB20, 36 bytes long.
 Data: <  6     o  <-   > A0 F2 36 01 01 00 00 00 6F 12 03 3C 2D 00 00 00 
{100} normal block at 0x010EBAC0, 36 bytes long.
 Data: <  6     X9 <-   > 8C F5 36 01 01 00 00 00 58 39 B4 3C 2D 00 00 00 
{96} normal block at 0x010EB958, 36 bytes long.
 Data: <\ 9     o  :+   > 5C 05 39 01 01 00 00 00 6F 12 83 3A 2B 00 00 00 
{94} normal block at 0x010EB8A0, 36 bytes long.
 Data: <  9     o  :*   > B0 01 39 01 01 00 00 00 6F 12 83 3A 2A 00 00 00 
{93} normal block at 0x010EB840, 36 bytes long.
 Data: <  6      / <)   > 90 EC 36 01 01 00 00 00 1B 2F DD 3C 29 00 00 00 
{91} normal block at 0x010EB788, 36 bytes long.
 Data: <  6     o  ;&   > A4 EC 36 01 01 00 00 00 6F 12 03 3B 26 00 00 00 
{89} normal block at 0x010EB728, 36 bytes long.
 Data: <  8      t <    > B4 FF 38 01 01 00 00 00 BC 74 93 3C 14 00 00 00 
{88} normal block at 0x010EB6C8, 36 bytes long.
 Data: <  8       D;    > 98 FF 38 01 01 00 00 00 A6 9B 44 3B 11 00 00 00 
{86} normal block at 0x010EB218, 36 bytes long.
 Data: <h 8        ;    > 68 FF 38 01 01 00 00 00 A6 9B C4 3B 0B 00 00 00 
{85} normal block at 0x010EB1B8, 36 bytes long.
 Data: <t 8      / <    > 74 FF 38 01 01 00 00 00 1B 2F DD 3C 0B 00 00 00 
{84} normal block at 0x010EB158, 36 bytes long.
 Data: <  6     o  <    > E8 EC 36 01 01 00 00 00 6F 12 03 3C 03 00 00 00 
{83} normal block at 0x010EB0F8, 36 bytes long.
 Data: <H 6     P  =    > 48 EC 36 01 01 00 00 00 50 8D 97 3D 03 00 00 00 
{82} normal block at 0x010EB098, 36 bytes long.
 Data: <8 6        =    > 38 EC 36 01 01 00 00 00 9E EF A7 3D 01 00 00 00 
{34} normal block at 0x01086090, 32 bytes long.
 Data: <v /     &d      > 76 E5 2F 00 00 00 00 00 26 64 BF 13 CD CD CD CD 
Object dump complete. 
Most of that leakage seems to come from the stepping loop. Otherwise I just end up with this one:

Code: Select all

{34} normal block at 0x012D6090, 32 bytes long.
 Data: <v /             > 76 E5 2F 00 00 00 00 00 F0 F4 BF 13 CD CD CD CD 
Even when I execute no Bullet code and just have btBulletDynamics.h #included, it leaks those 32 bytes.

Is this happening for anyone else?

Re: Memory leaking in Visual Studio 11

Posted: Fri Mar 30, 2012 3:30 pm
by DannyChapman
I found something similar (and posted about it too) - it was due to the profiling code. When I disabled that the leaks stopped. I didn't investigate properly though.

Re: Memory leaking in Visual Studio 11

Posted: Fri Mar 30, 2012 3:38 pm
by Erwin Coumans
I haven't looked into it yet, but this should be fixed indeed.
Good point Danny. The profiling should be disabled by default with an API to enable it (perhaps using a singleton).


Can you try to disable profiling in Bullet/src/LinearMath/btQuickprof.h, by uncommenting the line at the top so it becomes:

Code: Select all

#define BT_NO_PROFILE 1
Let us know if that fixes it for you.

Re: Memory leaking in Visual Studio 11

Posted: Fri Mar 30, 2012 6:19 pm
by reinux
Thanks, looks like that did the trick.