Hello Pan,
li pan wrote:
> Hi all.
> I got memory leak with OpenSG1.8 in debug mode on windows/VS2005.
>
> To reproduce the problem, simply comment out some code of 01hello.cpp, like
> this
>
> // Init the OpenSG subsystem
> osgInit(argc,argv);
>
> /* commented out
> // GLUT init
> int winid = setupGLUT(&argc, argv);
> // the connection between GLUT and OpenSG
> GLUTWindowPtr gwin= GLUTWindow::create();
> gwin->setId(winid);
> gwin->init();
> // create the scene
> NodePtr scene = makeTorus(.5, 2, 16, 16);
> // create the SimpleSceneManager helper
> mgr = new SimpleSceneManager;
> // tell the manager what to manage
> mgr->setWindow(gwin );
> mgr->setRoot (scene);
> // show the whole scene
> mgr->showAll();
> // GLUT main loop
> glutMainLoop();*/
>
> Then I checked VS memory leak by
> MS function "_CrtMemDumpAllObjectsSince( NULL );"
>
> It prints a long memory leak list, like this
>
> {203} normal block at 0x02576B38, 32 bytes long.
> Data: < oW ( > 90 6F 57 02 C8 09 90 02 28 08 90 02 CD CD CD CD
> {202} normal block at 0x02576A00, 248 bytes long.
> Data: < c= c= > 0C 63 3D 10 14 63 3D 10 00 00 00 00 CD CD CD CD
> c:\opensgsource\base\base\osglog.cpp(367) : {162} normal block at
> 0x02576948, 56 bytes long.
> Data: < 8 8 > EC F8 38 10 E8 F8 38 10 00 00 00 00 00 00 00 00
> c:\opensgsource\base\base\osglog.cpp(367) : {160} normal block at
> 0x02576890, 56 bytes long.
> Data: < 8 8 > EC F8 38 10 E8 F8 38 10 00 00 00 00 04 00 00 00
> c:\opensgsource\base\base\osglog.cpp(367) : {158} normal block at
> 0x025767D8, 56 bytes long.
> Data: < 8 8 > EC F8 38 10 E8 F8 38 10 00 00 00 00 00 00 00 00
>
I'm not really familiar with _CrtMemDumpAllObjectsSince, but according
to the documentation it prints information about memory that is
allocated. IIUC this does not mean that memory has been leaked it is
just in use. It would become a leak if it was not freed once it is no
longer needed.
> But 01hello.cpp itself doesn't have memory leak, what I have done is
> to comment all lines except osgInit()
>
> So do I always have to create a GLUT windows to avoid memory leak?
Hm, no. Does creating a GLUTWindow have an effect on the list of
allocations you see ?
> Those memory leak are in osglog.cpp, which codes are supposed to clean
> up those memory block?
The line number in the messages above point to the constructor of
OSG::Log, which should only run once. It does some allocations, but
those basically have to remain until the program exits, because
otherwise logging will not be functional beyond some point, which is not
really desirable.
Hope it helps,
Carsten
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Opensg-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/opensg-users