Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit Classic Chat / Local array going out of scope

Author
Message
Jambo B
15
Years of Service
User Offline
Joined: 17th Sep 2009
Location: The Pit
Posted: 28th Mar 2015 15:04 Edited at: 29th Mar 2015 00:20
Hello all,

I want to avoid memory leaks. Can arrays be defined as local, and when out of scope, are they automatically deleted?



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
Markus
Valued Member
20
Years of Service
User Offline
Joined: 10th Apr 2004
Location: Germany
Posted: 28th Mar 2015 20:32 Edited at: 29th Mar 2015 04:09
i believe u can undim with TempArray.length=-1
your code looks correct, i would also expect the memory will free up
after this function.
if the compiler make this array global there should be come an error missing
"global "
agk is a little bit uncommon at some points.
just try if you can access this out of scope.

AGK 108 (B)19 + AppGameKit V2 Alpha .. : Windows 8.1 Pro 64 Bit : AMD Radeon R7 265 : Mac mini OS X 10.10 (Yosemite)
Mike Archer
9
Years of Service
User Offline
Joined: 19th Feb 2015
Location: Wales
Posted: 29th Mar 2015 02:03
Local arrays/variables are deleted when the function exits, here's a quick example of code to demonstrate this, run task manager and you can see the memory get eaten up and free again as the code runs.

Login to post a reply

Server time is: 2024-11-25 18:32:10
Your offset time is: 2024-11-25 18:32:10