Posts: 580
Threads: 26
Joined: Jan 2006
Reputation:
0
Yes.
A pawn cell is 32 bit - 4 bytes, so if it's a global the script will use that memory pre-initialized in the amx file itself.
If it's a local, it will be added to the reserved stack portion, and everything ofcourse uses up ram..
Posts: 10,066
Threads: 38
Joined: Sep 2007
Reputation:
0
Yes, memory is freed as soon as the function ends. The thing is: why would you need the extra space if you're not going to use anyway? As JernejL already pointed out, there is a reserved stack portion to which all local variables are saved during function calls. If you use too much large arrays, the stack can eventually overflow and cause all kind of errors where variables overwrite each other.
Posts: 367
Threads: 55
Joined: Oct 2011
Reputation:
0
Thanks a lot! If I can overflow the stack, what is the limit?
Posts: 10,066
Threads: 38
Joined: Sep 2007
Reputation:
0
15 kilobytes or so, I believe. You can check that using the heapspace() native. The function returns the space left on the stack/heap in bytes, so you'll need to divide by 1024 to get kilobytes.
Posts: 367
Threads: 55
Joined: Oct 2011
Reputation:
0
Thanks a lot for the info!