Hi All,
Has anybody done any memory leak analysis of OpenSG on Windows ?
I tried to figure out if there are any memory leaks in OpenSG on
Windows and got few memory leaks. Here is what I did :
I took OpenSG tutorial example 01hello.cpp and made two cut short
versions of it :
Program 1 : containing just osgInit and osgExit
Program 2 : 01hello.cpp without glut motion and mouse callbacks etc
[Code for these two programs is pasted below together with their
memory dump statistics]
Running these two programs in debug mode (with OpenSG debug libraries)
shows following memory leak statistics :
Program 1 (OpenSG 1.6) : 176 bytes leaked
Program 1 (OpenSG current CVS build) : 4 bytes leaked
Program 2 (OpenSG 1.6) : 343000 bytes leaked
Program 2 (OpenSG current CVS build) : 350116 bytes leaked
Is this kind of memory leak expected or already known to exist ? Is
there anyway to avoid/fix these memory leaks ? My only worry is that
if we increase the complexity of the application the memory leak might
go even higher.
Any comments ?
Thanks,
- Vaibhav
-------------------------------------------------------
Program 1 :
#define CRTDBG_MAP_ALLOC
#define _CRTDBG_MAP_ALLOC
#include <stdlib.h>
#include <crtdbg.h>
#include <OpenSG/OSGConfig.h>
#include <OpenSG/OSGSimpleGeometry.h>
OSG_USING_NAMESPACE
int main(int argc, char **argv)
{
_CrtMemState s1, s2, s3;
_CrtMemCheckpoint( &s1 );
osgInit(argc,argv);
OSG::osgExit();
_CrtMemCheckpoint( &s2 );
std::cout<<"\nMemory Dump of difference if any\n";
if ( _CrtMemDifference( &s3, &s1, &s2) )
_CrtMemDumpStatistics( &s3 );
return 0;
}
Memory Dump Statistics for Program 1:
With OpenSG 1.6 debug libs:
Memory Dump of difference if any
0 bytes in 0 Free Blocks.
176 bytes in 5 Normal Blocks.
91 bytes in 7 CRT Blocks.
0 bytes in 0 Ignore Blocks.
0 bytes in 0 Client Blocks.
Largest number used: 443 bytes.
Total allocations: 527 bytes.
With OpenSG current CVS (debug) build:
0 bytes in 0 Free Blocks.
4 bytes in 1 Normal Blocks.
91 bytes in 7 CRT Blocks.
0 bytes in 0 Ignore Blocks.
0 bytes in 0 Client Blocks.
Largest number used: 443 bytes.
Total allocations: 527 bytes.
---------------------------------------------------
Program 2 :
#define CRTDBG_MAP_ALLOC
#define _CRTDBG_MAP_ALLOC
#include <stdlib.h>
#include <crtdbg.h>
_CrtMemState s1, s2, s3;
#include <OpenSG/OSGGLUT.h>
#include <OpenSG/OSGConfig.h>
#include <OpenSG/OSGSimpleGeometry.h>
#include <OpenSG/OSGGLUTWindow.h>
#include <OpenSG/OSGSimpleSceneManager.h>
OSG_USING_NAMESPACE
SimpleSceneManager *mgr;
int setupGLUT( int *argc, char *argv[] );
int main(int argc, char **argv)
{
_CrtMemCheckpoint( &s1 );
osgInit(argc,argv);
int winid = setupGLUT(&argc, argv);
GLUTWindowPtr gwin= GLUTWindow::create();
gwin->setId(winid);
gwin->init();
NodePtr scene = makeTorus(.5, 2, 16, 16);
mgr = new SimpleSceneManager;
mgr->setWindow(gwin );
mgr->setRoot (scene);
mgr->showAll();
glutMainLoop();
return 0;
}
void display(void)
{
mgr->redraw();
}
void reshape(int w, int h)
{
mgr->resize(w, h);
glutPostRedisplay();
}
void keyboard(unsigned char k, int x, int y)
{
switch(k)
{
case 27:
{
OSG::osgExit();
_CrtMemCheckpoint( &s2 );
if ( _CrtMemDifference( &s3, &s1, &s2) )
_CrtMemDumpStatistics( &s3 );
exit(0);
}
break;
}
}
int setupGLUT(int *argc, char *argv[])
{
glutInit(argc, argv);
glutInitDisplayMode(GLUT_RGB | GLUT_DEPTH | GLUT_DOUBLE);
int winid = glutCreateWindow("OpenSG");
glutReshapeFunc(reshape);
glutDisplayFunc(display);
glutKeyboardFunc(keyboard);
return winid;
}
Memory dump statistics for Program 2 :
With OpenSG 1.6 debug libs:
0 bytes in 0 Free Blocks.
343000 bytes in 950 Normal Blocks.
91 bytes in 7 CRT Blocks.
0 bytes in 0 Ignore Blocks.
0 bytes in 0 Client Blocks.
Largest number used: 397583 bytes.
Total allocations: 683201 bytes.
With OpenSG current CVS (debug) build:
0 bytes in 0 Free Blocks.
350116 bytes in 987 Normal Blocks.
91 bytes in 7 CRT Blocks.
0 bytes in 0 Ignore Blocks.
0 bytes in 0 Client Blocks.
Largest number used: 471629 bytes.
Total allocations: 789543 bytes.
-----------------------------------------------------------------
-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Opensg-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/opensg-users