Memory leaks
v71 opened this issue · comments
Just creating the PhysicsCommon causes a massive amounts of memory leakage
Dumping objects ->
{239} normal block at 0x0000023F105CE070, 5242920 bytes long.
Data: < > 00 02 00 00 00 00 00 00 01 CD CD CD CD CD CD CD
{238} normal block at 0x0000023F0EC70620, 16 bytes long.
Data: < 'O > 00 83 27 4F F6 7F 00 00 00 00 00 00 00 00 00 00
{237} normal block at 0x0000023F0EC71390, 16 bytes long.
Data: < 'O > D0 82 27 4F F6 7F 00 00 00 00 00 00 00 00 00 00
{236} normal block at 0x0000023F0EC70C10, 16 bytes long.
Data: < 'O > A0 82 27 4F F6 7F 00 00 00 00 00 00 00 00 00 00
{235} normal block at 0x0000023F0EC70CB0, 16 bytes long.
Data: <p 'O > 70 82 27 4F F6 7F 00 00 00 00 00 00 00 00 00 00
{234} normal block at 0x0000023F0EC70580, 16 bytes long.
Data: <@ 'O > 40 82 27 4F F6 7F 00 00 00 00 00 00 00 00 00 00
{233} normal block at 0x0000023F0EC70C60, 16 bytes long.
Data: < 'O > 10 82 27 4F F6 7F 00 00 00 00 00 00 00 00 00 00
{232} normal block at 0x0000023F0EC70760, 16 bytes long.
Data: < 'O > E0 81 27 4F F6 7F 00 00 00 00 00 00 00 00 00 00
{231} normal block at 0x0000023F0EC70800, 16 bytes long.
Data: < 'O > B0 81 27 4F F6 7F 00 00 00 00 00 00 00 00 00 00
{230} normal block at 0x0000023F0EC70D00, 16 bytes long.
Data: < 'O > 80 81 27 4F F6 7F 00 00 00 00 00 00 00 00 00 00
{229} normal block at 0x0000023F0EC706C0, 16 bytes long.
Data: <P 'O > 50 81 27 4F F6 7F 00 00 00 00 00 00 00 00 00 00
{228} normal block at 0x0000023F0EC6F5E0, 16 bytes long.
Data: < 'O > 20 81 27 4F F6 7F 00 00 00 00 00 00 00 00 00 00
{227} normal block at 0x0000023F0EC6F590, 16 bytes long.
Data: < 'O > F0 80 27 4F F6 7F 00 00 00 00 00 00 00 00 00 00
{226} normal block at 0x0000023F0EC6F4F0, 16 bytes long.
Data: < 'O > C0 80 27 4F F6 7F 00 00 00 00 00 00 00 00 00 00
{225} normal block at 0x0000023F0EC6F4A0, 16 bytes long.
Data: < 'O > 90 80 27 4F F6 7F 00 00 00 00 00 00 00 00 00 00
{224} normal block at 0x0000023F0EC6F540, 16 bytes long.
Data: < 'O > 60 80 27 4F F6 7F 00 00 00 00 00 00 00 00 00 00 {223} normal block at 0x0000023F0EC6FFE0, 16 bytes long. Data: <0 'O > 30 80 27 4F F6 7F 00 00 00 00 00 00 00 00 00 00 {222} normal block at 0x0000023F0EC6FB80, 16 bytes long. Data: < 'O > 00 80 27 4F F6 7F 00 00 00 00 00 00 00 00 00 00 {221} normal block at 0x0000023F0EC6FB30, 16 bytes long. Data: < 'O > D0 7F 27 4F F6 7F 00 00 00 00 00 00 00 00 00 00 {219} normal block at 0x0000023F0EC6FF40, 16 bytes long. Data: < 'O > A0 7F 27 4F F6 7F 00 00 00 00 00 00 00 00 00 00 {218} normal block at 0x0000023F0EC6F9F0, 16 bytes long. Data: <p 'O > 70 7F 27 4F F6 7F 00 00 00 00 00 00 00 00 00 00 {217} normal block at 0x0000023F0EC6F450, 16 bytes long. Data: <@ 'O > 40 7F 27 4F F6 7F 00 00 00 00 00 00 00 00 00 00 {216} normal block at 0x0000023F0EC6F9A0, 16 bytes long. Data: < 'O > 10 7F 27 4F F6 7F 00 00 00 00 00 00 00 00 00 00 {215} normal block at 0x0000023F0EC6F950, 16 bytes long. Data: < ~'O > E0 7E 27 4F F6 7F 00 00 00 00 00 00 00 00 00 00 {214} normal block at 0x0000023F0EC6F310, 16 bytes long. Data: < ~'O > B0 7E 27 4F F6 7F 00 00 00 00 00 00 00 00 00 00 {213} normal block at 0x0000023F0EC6FEA0, 16 bytes long. Data: < ~'O > 80 7E 27 4F F6 7F 00 00 00 00 00 00 00 00 00 00 {212} normal block at 0x0000023F0EC6F720, 16 bytes long. Data: <P~'O > 50 7E 27 4F F6 7F 00 00 00 00 00 00 00 00 00 00 {211} normal block at 0x0000023F0EC6F130, 16 bytes long. Data: < ~'O > 20 7E 27 4F F6 7F 00 00 00 00 00 00 00 00 00 00 {210} normal block at 0x0000023F0EC6FA90, 16 bytes long. Data: < }'O > F0 7D 27 4F F6 7F 00 00 00 00 00 00 00 00 00 00 {209} normal block at 0x0000023F0EC6F8B0, 16 bytes long. Data: < }'O > C0 7D 27 4F F6 7F 00 00 00 00 00 00 00 00 00 00 {208} normal block at 0x0000023F0EC6F7C0, 16 bytes long. Data: < }'O > 90 7D 27 4F F6 7F 00 00 00 00 00 00 00 00 00 00 {207} normal block at 0x0000023F0EC6F900, 16 bytes long. Data: <
}'O > 60 7D 27 4F F6 7F 00 00 00 00 00 00 00 00 00 00
{206} normal block at 0x0000023F0EC70030, 16 bytes long.
Data: <0}'O > 30 7D 27 4F F6 7F 00 00 00 00 00 00 00 00 00 00
{205} normal block at 0x0000023F0EC6FE50, 16 bytes long.
Data: < }'O > 00 7D 27 4F F6 7F 00 00 00 00 00 00 00 00 00 00
{204} normal block at 0x0000023F0EC6F810, 16 bytes long.
Data: < |'O > D0 7C 27 4F F6 7F 00 00 00 00 00 00 00 00 00 00
{203} normal block at 0x0000023F0EC6F2C0, 16 bytes long.
Data: < |'O > A0 7C 27 4F F6 7F 00 00 00 00 00 00 00 00 00 00
{202} normal block at 0x0000023F0EC6FAE0, 16 bytes long.
Data: <p|'O > 70 7C 27 4F F6 7F 00 00 00 00 00 00 00 00 00 00
{201} normal block at 0x0000023F0EC6F630, 16 bytes long.
Data: <@|'O > 40 7C 27 4F F6 7F 00 00 00 00 00 00 00 00 00 00
{200} normal block at 0x0000023F0EC6F400, 16 bytes long.
Data: < |'O > 10 7C 27 4F F6 7F 00 00 00 00 00 00 00 00 00 00
{199} normal block at 0x0000023F0EC6F6D0, 16 bytes long.
Data: < {'O > E0 7B 27 4F F6 7F 00 00 00 00 00 00 00 00 00 00
{198} normal block at 0x0000023F0EC6FC20, 16 bytes long.
Data: < {'O > B0 7B 27 4F F6 7F 00 00 00 00 00 00 00 00 00 00
{197} normal block at 0x0000023F0EC6F220, 16 bytes long.
Data: < {'O > 80 7B 27 4F F6 7F 00 00 00 00 00 00 00 00 00 00
{196} normal block at 0x0000023F0EC6FE00, 16 bytes long.
Data: <P{'O > 50 7B 27 4F F6 7F 00 00 00 00 00 00 00 00 00 00
{195} normal block at 0x0000023F0EC6F0E0, 16 bytes long.
Data: < {'O > 20 7B 27 4F F6 7F 00 00 00 00 00 00 00 00 00 00
{194} normal block at 0x0000023F0EC6FF90, 16 bytes long.
Data: < z'O > F0 7A 27 4F F6 7F 00 00 00 00 00 00 00 00 00 00
{193} normal block at 0x0000023F0EC6F270, 16 bytes long.
Data: < z'O > C0 7A 27 4F F6 7F 00 00 00 00 00 00 00 00 00 00
{192} normal block at 0x0000023F0EC6FEF0, 16 bytes long.
Data: < z'O > 90 7A 27 4F F6 7F 00 00 00 00 00 00 00 00 00 00
{191} normal block at 0x0000023F0EC6FDB0, 16 bytes long.
Data: <`z'O > 60 7A 27 4F F6 7F 00 00 00 00 00 00 00 00 00 00
{190} normal block at 0x0000023F0EC6FD60, 16 bytes long.
Data: <0z'O > 30 7A 27 4F F6 7F 00 00 00 00 00 00 00 00 00 00
{189} normal block at 0x0000023F0EC6F360, 16 bytes long.
Data: < z'O > 00 7A 27 4F F6 7F 00 00 00 00 00 00 00 00 00 00
{188} normal block at 0x0000023F0EC6FA40, 16 bytes long.
Data: < y'O > D0 79 27 4F F6 7F 00 00 00 00 00 00 00 00 00 00
{186} normal block at 0x0000023F0EC6FBD0, 16 bytes long.
Data: < y'O > A0 79 27 4F F6 7F 00 00 00 00 00 00 00 00 00 00
{185} normal block at 0x0000023F0EC6FCC0, 16 bytes long.
Data: <py'O > 70 79 27 4F F6 7F 00 00 00 00 00 00 00 00 00 00
{184} normal block at 0x0000023F0EC6F1D0, 16 bytes long.
Data: <@y'O > 40 79 27 4F F6 7F 00 00 00 00 00 00 00 00 00 00
{183} normal block at 0x0000023F0EC6F180, 16 bytes long.
Data: < y'O > 10 79 27 4F F6 7F 00 00 00 00 00 00 00 00 00 00
{182} normal block at 0x0000023F0EC6FD10, 16 bytes long.
Data: < x'O > E0 78 27 4F F6 7F 00 00 00 00 00 00 00 00 00 00
{181} normal block at 0x0000023F0EC6F680, 16 bytes long.
Data: < x'O > B0 78 27 4F F6 7F 00 00 00 00 00 00 00 00 00 00
{180} normal block at 0x0000023F0EC6F770, 16 bytes long.
Data: < x'O > 80 78 27 4F F6 7F 00 00 00 00 00 00 00 00 00 00
{179} normal block at 0x0000023F0EC6FC70, 16 bytes long.
Data: <Px'O > 50 78 27 4F F6 7F 00 00 00 00 00 00 00 00 00 00
{178} normal block at 0x0000023F0EC6F3B0, 16 bytes long.
Data: < x'O > 20 78 27 4F F6 7F 00 00 00 00 00 00 00 00 00 00
{177} normal block at 0x0000023F0EC6F860, 16 bytes long.
Data: < w'O > F0 77 27 4F F6 7F 00 00 00 00 00 00 00 00 00 00
{176} normal block at 0x0000023F0EC6C020, 16 bytes long.
Data: < w'O > C0 77 27 4F F6 7F 00 00 00 00 00 00 00 00 00 00
{175} normal block at 0x0000023F0EC6CED0, 16 bytes long.
Data: < w'O > 90 77 27 4F F6 7F 00 00 00 00 00 00 00 00 00 00
{174} normal block at 0x0000023F0EC6CD90, 16 bytes long.
Data: <0w'O > 30 77 27 4F F6 7F 00 00 00 00 00 00 00 00 00 00
{173} normal block at 0x0000023F0EC6CC00, 16 bytes long.
Data: < w'O > 00 77 27 4F F6 7F 00 00 00 00 00 00 00 00 00 00
{172} normal block at 0x0000023F0EC6CBB0, 16 bytes long.
Data: < v'O > D0 76 27 4F F6 7F 00 00 00 00 00 00 00 00 00 00
{171} normal block at 0x0000023F0EC6CC50, 16 bytes long.
Data: < v'O > A0 76 27 4F F6 7F 00 00 00 00 00 00 00 00 00 00
{170} normal block at 0x0000023F0EC6CB10, 16 bytes long.
Data: <pv'O > 70 76 27 4F F6 7F 00 00 00 00 00 00 00 00 00 00
{169} normal block at 0x0000023F0EC6C980, 16 bytes long.
Data: <@v'O > 40 76 27 4F F6 7F 00 00 00 00 00 00 00 00 00 00
{168} normal block at 0x0000023F0EC6C4D0, 16 bytes long.
Data: < v'O > 10 76 27 4F F6 7F 00 00 00 00 00 00 00 00 00 00
{167} normal block at 0x0000023F0EC6C840, 16 bytes long.
Data: < u'O > E0 75 27 4F F6 7F 00 00 00 00 00 00 00 00 00 00
{166} normal block at 0x0000023F0EC6C9D0, 16 bytes long.
Data: < u'O > B0 75 27 4F F6 7F 00 00 00 00 00 00 00 00 00 00
{165} normal block at 0x0000023F0EC6C7F0, 16 bytes long.
Data: <xu'O > 78 75 27 4F F6 7F 00 00 00 00 00 00 00 00 00 00
{164} normal block at 0x0000023F0EC6CE80, 16 bytes long.
Data: <@U'O > 40 75 27 4F F6 7F 00 00 00 00 00 00 00 00 00 00
{163} normal block at 0x0000023F0EC6C480, 16 bytes long.
Data: < u'O > 10 75 27 4F F6 7F 00 00 00 00 00 00 00 00 00 00
{162} normal block at 0x0000023F0EC6C430, 16 bytes long.
Data: < t'O > E0 74 27 4F F6 7F 00 00 00 00 00 00 00 00 00 00
{161} normal block at 0x0000023F0EC6C750, 16 bytes long.
Data: < t'O > B0 74 27 4F F6 7F 00 00 00 00 00 00 00 00 00 00
{160} normal block at 0x0000023F0EC6C1B0, 16 bytes long.
Data: <xp'O > 78 70 27 4F F6 7F 00 00 00 00 00 00 00 00 00 00
{159} normal block at 0x0000023F0EC6CAC0, 16 bytes long.
Data: <0'O > 30 5C 27 4F F6 7F 00 00 00 00 00 00 00 00 00 00
Object dump complete.
What am I doing wrong ?
Can I ask you what are those logs? Where are they coming from?
Ok, first of all sorry if i misplaced my post, i left another post in the discussion forums, weeks ago, and looks like nobody have the same issues we are having. For a project of my company , we are evaluating 3rd party 3d libs. The logs come from the visual studio 2022 debugger. To reproduce it , create a blank console application in debug mode
Do you have an error message somewhere? Can you paste your complete code here? Can you also try to compile the "Hello World" application and see if you have the same issue?
This is the most basic things we wrote
visual studio 2022 , c++17.
also we noticed 12 warnings related to uninitialized variables in various classes ( yes we tried the hello world app )
Before you ask, we also tried to move the physicscommon class out of main, allocate it using 'new' and freeing, but the problems still persists
#pragma warning(disable:6386)
#pragma warning(disable:26451)
// debug_new.cpp
// compile by using: cl /EHsc /W4 /D_DEBUG /MDd debug_new.cpp
#define _CRTDBG_MAP_ALLOC
#include
#include <crtdbg.h>
#ifdef _DEBUG
#define DBG_NEW new ( _NORMAL_BLOCK , FILE , LINE )
// Replace _NORMAL_BLOCK with _CLIENT_BLOCK if you want the
// allocations to be of _CLIENT_BLOCK type
#else
#define DBG_NEW new
#endif
/////////////////////////////////////////////////////////////////////////////////////////////
#include <vml2.0\libs\reactphysics3d\reactphysics3d\reactphysics3d.h>
using namespace reactphysics3d;
///////////////////////////////////////////////////////////////////////////////////////////////////
int main()
{
_CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF | _CRTDBG_REPORT_FLAG);
_CrtSetReportMode(_CRT_ERROR, _CRTDBG_MODE_DEBUG);
PhysicsCommon physicsCommon;
_CrtDumpMemoryLeaks();
return 0;
}
I am not familiar with _CrtDumpMemoryLeaks() (I only use valgrind on Linux to check this) but in your code when this function is called the memory as not been released yet (the call is before the return statement). In your pointer version of that code, did you call _CrtDumpMemoryLeaks() after the delete statement?
Is this tool able to tell where in the code the leaks are happening (like valgrind)?
The visual studio memory leak detector does not give the line(s) where the offending code is located, yes , the code structure stays the same, , no matter how you instantiate physicscommon, the leak detector always reports those memory leaks
yes , the code structure stays the same, , no matter how you instantiate physicscommon, the leak detector always reports those memory leaks
Yes but I mean you are aware that in your code example above you test for leaks BEFORE releasing memory and therefore it's normal to find leaks in this situation. In your code above the destructor of the "physicsCommon" instance has not been called when you call _CrtDumpMemoryLeaks(). The destructor is only call at the end of the main function. Can you confirm that your code above is wrong or is there something I misunderstand?
Sorry , I forgot to mention that I use visual studio 2022 with my current language , ( italian ) , in the debugger windows you are seeing uninitialized variables along with class information
Hello. I took some time to investigate this. I am able to reproduce your results. I tried to break at the memory allocations with possible leaks. However, the only ones that I am able to break on, are allocations that are correctly released at the end. I tried to use two other different memory leak debuggers (valgrind and VLD) and they don't find any leak for the same example. I don't know if those results are part of the possible false positives of the CRT leak detection that are described here but I am not able to prove the memory leaks.
I don't have enough experience with the CRT memory leak detector of Visual Studio to go further. I will close this issue for the moment but feel free to let me know if you an any idea how to proceed to prove there are indeed memory leaks.