A place to discuss everything related to Newton Dynamics.
Moderators: Sascha Willems, walaber
by pHySiQuE » Tue Jul 31, 2012 6:23 pm
With an empty world, I am leaking memory each call to NewtonUpdate, in the amount of either 320, 480, or 640 bytes each call.
NewtonWorldGetFirstBody() returns NULL, indicating the world is empty.
-
pHySiQuE
-
- Posts: 608
- Joined: Fri Sep 02, 2011 9:54 pm
by Julio Jerez » Tue Jul 31, 2012 7:26 pm
I do not think there are not leaks in the engine. NewtonWorldGetFirstBody is use but almost every demo.
and the demos runn with debug memory check on
#ifdef _MSC_VER
_CrtSetDbgFlag( _CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF );
#endif
I never call with an emorty world, but I do not see why it will be different
-
Julio Jerez
- Moderator

-
- Posts: 12426
- Joined: Sun Sep 14, 2003 2:18 pm
- Location: Los Angeles
-
by Julio Jerez » Tue Jul 31, 2012 7:37 pm
I just trtied this, and I did nio get any report of leak
- Code: Select all
int main(int argc, char *argv[])
{
// Enable run-time memory check for debug builds.
#ifdef _MSC_VER
_CrtSetDbgFlag( _CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF );
#endif
NewtonWorld* xxx = NewtonCreate ();
NewtonWorldGetFirstBody(xxx) ;
NewtonDestroy(xxx);
}
-
Julio Jerez
- Moderator

-
- Posts: 12426
- Joined: Sun Sep 14, 2003 2:18 pm
- Location: Los Angeles
-
by pHySiQuE » Wed Aug 01, 2012 1:01 am
It's NewtonUpdate() that appears to leak. I'll try to isolate the problem tomorrow.
-
pHySiQuE
-
- Posts: 608
- Joined: Fri Sep 02, 2011 9:54 pm
by pHySiQuE » Wed Aug 01, 2012 4:34 pm
Yep, this produces a memleak:
- Code: Select all
int main(int argc, char *argv[])
{
// Enable run-time memory check for debug builds.
#ifdef _MSC_VER
_CrtSetDbgFlag( _CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF );
#endif
NewtonWorld* xxx = NewtonCreate ();
NewtonWorldGetFirstBody(xxx) ;
NewtonUpdate(xxx,1.0/60.0);
NewtonDestroy(xxx);
}}
-
pHySiQuE
-
- Posts: 608
- Joined: Fri Sep 02, 2011 9:54 pm
by Julio Jerez » Wed Aug 01, 2012 5:11 pm
I jst pasted liek this in teh sandbox demos, and I do no get any leaks
- Code: Select all
int main(int argc, char *argv[])
{
// Enable run-time memory check for debug builds.
#ifdef _MSC_VER
_CrtSetDbgFlag( _CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF );
#endif
NewtonWorld* xxx = NewtonCreate ();
NewtonWorldGetFirstBody(xxx) ;
NewtonUpdate(xxx,1.0/60.0);
NewtonDestroy(xxx);
/*
// Enable run-time memory check for debug builds.
#ifdef _MSC_VER
_CrtSetDbgFlag( _CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF );
#endif
FXApp application("Newton Dynamics demos", "Newton Dynamics demos");
// Set the memory allocation function before creation the newton world
// this is the only function that can be called before the creation of the newton world.
*/
}
I am very careful with leaks in the libraries, I will be very supriced if that generate some leak.
Therare are not global allocations or global classes that allocate memory in the engine.
My guess is that you must have some global calss that is leaving the leaks
-
Julio Jerez
- Moderator

-
- Posts: 12426
- Joined: Sun Sep 14, 2003 2:18 pm
- Location: Los Angeles
-
by pHySiQuE » Fri Aug 10, 2012 9:43 pm
I sent you a Visual Studio 2008 project demonstrating a memory leak in NewtonUpdate. Hopefully this will help identify the problem.
-
pHySiQuE
-
- Posts: 608
- Joined: Fri Sep 02, 2011 9:54 pm
by Julio Jerez » Sat Aug 11, 2012 8:12 am
Oh I see, your project setting are incorrect.
The reason is pthread leaves a memory leaks if static libraries is build with wrong library options.
in visual studio, you need to go to the project settings library that include prthread source code and do this:
options->preprocessor->Preprocessor definitions
and add these two define
PTW32_BUILD
PTW32_STATIC_LIB
try that see how that goes, the engine allocates about 300k/perworld of memory to initialize memory pools. each worlkd has his own local allocatios an dit sodul no grow is you do not create anything.
teh data will gown as contact joit are craeted bu i talway stbializes, teh engine whn no creation anything should run with zero memory allocations. I had being very careful about keeping that rigor over the entire engine.
-
Julio Jerez
- Moderator

-
- Posts: 12426
- Joined: Sun Sep 14, 2003 2:18 pm
- Location: Los Angeles
-
by pHySiQuE » Sun Aug 19, 2012 9:39 am
This fixes the problem. Thank you.
-
pHySiQuE
-
- Posts: 608
- Joined: Fri Sep 02, 2011 9:54 pm
Return to General Discussion
Who is online
Users browsing this forum: No registered users and 2 guests