Hi! Iam using Microsofts Visual c++. I have createt a windows forms application with a simple button. If i klick the button irrlicht wil create a window and load the world.
When i run the application and open the windows task manager i can see that my application uses 21,532k of Memory. And if i click my irrlicht button the Memory increases to 76,600k.
But when i close the irrlicht window the Memory of my application is not 21,532k again. Its about 33,000k. If i open and close the irrlicht window any times again the memory useage of my program becommes bigger and bigger.
I think there are undeletet irrlicht variables. I only use device->drop()
to destroy irrlicht.
Any ideas?
memory problem?
you do drop but what else?
code may help of your onevent,
code may help of your onevent,
Compete or join in irrlichts monthly screenshot competition!
Blog/site: http://rex.4vandorp.eu
Company: http://www.islandworks.eu/, InCourse
Twitter: @strong99
Blog/site: http://rex.4vandorp.eu
Company: http://www.islandworks.eu/, InCourse
Twitter: @strong99
hm..ok...here is the code: (i know that i have postes this code already in other topics...but i hope it will help other people too )
At first i have createt a struct:
Then i wrote 3 functions that will make, run and destroy world:
ok. and now whith the click on my button i call this:
thats it. After closing the irrlicht window destroy_world will be called. And after that the main program is still running and i can click the button again.
At first i have createt a struct:
Code: Select all
struct world
{
irr::IrrlichtDevice* device;
irr::gui::IGUIEnvironment* guienv;//playergui
ISceneManager* smgr;
IVideoDriver* driver;
irr::newton::IWorld* p_world;
irr::newton::IBody* fairy_body;//player collision body from newton
irr::scene::CCameraRPGSceneNode* mycam;
irr::scene::ITriangleSelector* selector;
irr::scene::ISceneNode* selectedSceneNode;//for objects selection
irr::scene::ISceneNode* lastSelectedSceneNode;//for objects selection
irr::scene::IAnimatedMeshSceneNode* fairy;
IGUIListBox* console;//console
irr::gui::IGUIButton* button_quit;
irr::gui::IGUIButton* button_tutorial;
irr::gui::IGUIButton* button_takephoto;
irr::gui::IGUIButton* button_editor;
irr::gui::IGUIButton* button_normalmode;
irr::gui::IGUIButton* button_newobject;
irr::gui::IGUIButton* button_deleteobject;
irr::gui::IGUIButton* button_texture;
irr::scene::IAnimatedMeshSceneNode* mymodel;
int mouse_over_gui;
int file_dialog_open;
int object_count;//how many objects are currently loaded
int editor_active;
int file_open_type;
int object_selected;
ISoundEngine* mysoundengine;//sound
VxCompass* pgCompass;//compass
};//end struct
Code: Select all
void init_world(world *myworld, System::String^ worldname)
{
//load device, world, player ,newton, irrklang, etc
}
void run_world(world *myworld)
{
while(myworld->device->run())
{...}
}
void destroy_world(world *myworld)
{
myworld->mysoundengine->stopAllSounds();
myworld->device->drop();
myworld = NULL;
}
ok. and now whith the click on my button i call this:
Code: Select all
world theworld;
init_world(&theworld,worldname);
run_world(&theworld);
destroy_world(&theworld);
You should be destroying/deallocating/dropping everything that you have a pointer to that needs to be cleaned up. If you have grabbed the gui elements and scene nodes, you should drop them. You should also have code to clean up your newton world and body, the sound engine, the compass.
You can enable the debug heap and at program exit it will tell you the file name, line and allocation number for the failed allocation. You can use that information to figure out where the memory leak is coming from. You can find more information about using the debug heap here http://msdn2.microsoft.com/en-us/librar ... s.71).aspx.
You could also use the Rational Purify tool to instrument your code and to help you locate your memory leaks. It is very easy to use and doesn't usually require you to make changes to your source code or project in any way.
You can enable the debug heap and at program exit it will tell you the file name, line and allocation number for the failed allocation. You can use that information to figure out where the memory leak is coming from. You can find more information about using the debug heap here http://msdn2.microsoft.com/en-us/librar ... s.71).aspx.
You could also use the Rational Purify tool to instrument your code and to help you locate your memory leaks. It is very easy to use and doesn't usually require you to make changes to your source code or project in any way.