Game Development Community

Easy question...

by Jared Hoberock · in Torque Game Engine · 02/27/2002 (1:33 am) · 1 replies

Is there a delete operator analogous to the new operator used in the scripts? Or do objects allocated in script functions get deleted when the function exits? For example:

function generateMission()
{
...
new TerrainBlock(Terrain)
{
...
}; // end TerrainBlock()

...
}; // end function generateMission()

Will Terrain stay resident in memory after this function exits? I don't want any memory leaks nor do I want this object to interfere with the real TerrainBlock that gets loaded when a mission begins.

Thanks for your input,
J

#1
02/27/2002 (5:28 am)
The terrain most certainly will remain in memory. The best way to ensure everything is cleaned up on mission end is to add the objects to missioncleanup group.

The missioncleanup group gets deleted on mission end along with all the objects in it.

so in your previous example:

function generateMission() 
{ 
... 
%bla = new TerrainBlock(Terrain) 
{ 
... 
}; // end TerrainBlock() 
MissionCleanup.add( %bla );

... 
}; // end function generateMission()

you can of course manually delete an object as well
Terrain.delete();