ScriptSpot

Forum topic · General Scripting

Delete an instance of a Structure (destructor)

By Rodman · 2013-12-09

Description

Hi,

The documentation doesn't mention how an instance of a structure is managed once it's created. Is there a destructor like in C++ ? In other words, can we release the memory used by this instance ?

I would say yes if you affect the value undefined to the instance but I'm not sure.

Also, if you create an instance twice (same name of the instance), the memory of the fisrt instance will be released or not ?

Comments (4)

barigazy · 2013-12-09

I think using "undefined" is the answer for all your questions

***

Rodman · 2013-12-09

Ok, so the code below is correct ?


Struct theStruct
(
 -- some stuffs here, allocating memory
)

instance = theStruct()

instance = undefined -- clear the memory
instance = theStruct()

barigazy · 2013-12-09

Yup. But don't use word "instance" as variable

Rodman · 2013-12-09

Okay thanks Branko !

Yes the example is just to explain the problem.