Hello all,
I want to avoid memory leaks. Can arrays be defined as local, and when out of scope, are they automatically deleted?
type MyType
sID as string
sContents as string[0]
iSomeOtherInteger as integer
endtype
function UseTheType()
TempArray as MyType[0]
for iterArray = 0 to 10
TempArray.length = TempArray.length + 1
TempArray[TempArray.length-1].sID = "The ID!"
for iterString = 0 to 5
TempArray[TempArray.length-1].sContents.length = TempArray[TempArray.length-1].sContents.length + 1
TempArray[TempArray.length-1].sContents[TempArray[TempArray.length-1].sContents.length-1] = "Added string"
next iterString
TempArray[TempArray.length-1].iSomeOtherInteger = random(1,1000)
next iterArray
// ... do some other stuff with temp array
// Will TempArray be deleted here?
endfunction
Is there anything wrong with the code above which might cause memory leaks? I tried an undim at the end of the function, but computer says no:
error: Array "temparray" has not been defined.
Thanks,
James