SA-MP Forums Archive
Question info: about string.. memory usage - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Question info: about string.. memory usage (/showthread.php?tid=365587)



Question info: about string.. memory usage - Speed++ - 03.08.2012

for my gamemode.. I decided to use a global one string with 1024 characters, for all formats.. ecc.. is good, or waste a lot of resources in this way ?


Re: Question info: about string.. memory usage - Misiur - 03.08.2012

I'd say it's a waste. You might get in trouble with heap/stack size, because this will occupy memory for the whole gamemode execution. If you create local variables with new in smaller scopes, you can use smaller, adequate sizes for shorter strings, and they won't occupy resources for so long.


Re: Question info: about string.. memory usage - sidney123 - 03.08.2012

That will be a huge waste of memory usage. Try to do 256 or 64.


Re: Question info: about string.. memory usage - Vince - 03.08.2012

Global variables are not stored on the stack or the heap. It might just work, but it's somewhat of a dangerous practice because you might inadvertently overwrite the string before it is output.


Re: Question info: about string.. memory usage - Speed++ - 03.08.2012

OK, thanks