Does device->drop() deletes memory allocation?

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
Pythy Python
Posts: 30
Joined: Sun Mar 29, 2015 1:31 am

Does device->drop() deletes memory allocation?

Post by Pythy Python »

Code: Select all

IrrlichtDevice *device = ...;
device->drop();
 
Does device->drop() deletes all pointer objects that I created?
CuteAlien
Admin
Posts: 9734
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: Does device->drop() deletes memory allocation?

Post by CuteAlien »

It's a reference-counting mechanism which does delete pointers when the reference count reaches null. In Irrlicht you only call drop() when you did call grab() before or when you did create the object with a function which has name starting with the word 'create' or when you created the object with new.

Please check the documentation: http://irrlicht.sourceforge.net/docu/cl ... unted.html
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Pythy Python
Posts: 30
Joined: Sun Mar 29, 2015 1:31 am

Re: Does device->drop() deletes memory allocation?

Post by Pythy Python »

So that means I don't have to do this,

Code: Select all

 
IrrlichtDevice *device = createDevice(...);
 
delete device;
 
instead I do this,

Code: Select all

 
device->drop();
 
am I correct?
CuteAlien
Admin
Posts: 9734
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: Does device->drop() deletes memory allocation?

Post by CuteAlien »

Yes, correct. But please take a look at the examples when learning the engine. At least example "01.Hello World" which shows the basics.
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Post Reply