Do I Have A Memory Leak? (Solved)

Io

So in my code, I do a lot of cloning objects. Like, you take your spaceship to a system, and it clones a bunch of CelestialBodyBase into the SpaceRoom (First changing the alias, so like CelestialBodyBase.alias="Sol", ="Earth", etc) to get the different stars and planets. When you go to a different system, I use FilterByAttribute to clean the old clones out.

foreach (SolarBody, FilterByAttribute(GetDirectChildren(SpaceRoom), "prototype", CelestialBodyBase)) {
 RemoveObject (SolarBody)

And I've thought this is all fine. But recently I opened the Debugger while testing one of the boss fights, and realized there was a TON of clones with their data still in the Debugger. CelestialBodyBase1, CelestialBodyBase2, etc. And those residual objects don't have a parent attribute, so I can only guess that 'Remove' merely 'removes' their parent attribute and puts them into nowhere, while not actually DELETING the object itself.

So my question is, how can I actually truly permanently delete these residual objects? Or is it not an issue and the Debugger is just being silly?


the 'RemoveObject (NAME_OF_OBJECT)' merely sets the Object's 'parent' Object (reference/pointer) to 'null' (the direct parent is the 'ASL' GAME OBJECT):

http://docs.textadventures.co.uk/quest/functions/corelibrary/removeobject.html

the 'destroy (NAME_OF_OBJECT_AS_A_STRING_DATA_TYPE)' destroys the Object (I'm not sure how memory/pointers/etc actually are done/handle in quest's internal coding though):

http://docs.textadventures.co.uk/quest/scripts/destroy.html


create ("npc")
// npc.parent = null

npc.parent = room

RemoveObject (npc)
// npc.parent = null

destroy (npc.name) // npc.name = "npc"
// or:
// destroy ("npc")
// or:
// string_variable = npc.name // or: string_variable = "npc"
// destroy (string_variable)

I think mrangel/pixie explained that quest safeguards, via:

every created Object (a pointer/reference to its address) is stored within a master/internal Objectlist (forgot the name of it) of the quest engine, so even if you mess anything up, its still in that master Objectlist and will/can be properly handled by quest engine


Io

Thank you! My debugger's looking nice and clean with this fix. A simple

destroy (ObjectIWantGone.name)

or

destroy (this.name)

as the situation warrants.


This topic is now closed. Topics are closed after 60 days of inactivity.

Support

Forums