Posts: 159
Threads: 42
Joined: Jun 2012
Reputation:
0
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 ?
Posts: 2,528
Threads: 124
Joined: Jul 2009
Reputation:
0
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.
Posts: 103
Threads: 18
Joined: Sep 2011
Reputation:
0
That will be a huge waste of memory usage. Try to do 256 or 64.
Posts: 10,066
Threads: 38
Joined: Sep 2007
Reputation:
0
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.