AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   arrays/strings memory usage (https://forums.alliedmods.net/showthread.php?t=20323)

commonbullet 11-06-2005 08:47

arrays/strings memory usage
 
consider the 3 situations:
Quote:

1: new test[32]
2: format (test,8,"testing")
3: format (test,1,"t")
Is there any difference in memory space used by "test" variable? or maybe the space is reserved in 1) (?) and it doesn't change.

PM 11-06-2005 10:57

Re: arrays/strings memory usage
 
Quote:

Originally Posted by commonbullet
consider the 3 situations:
Quote:

1: new test[32]
2: format (test,8,"testing")
3: format (test,1,"t")
Is there any difference in memory space used by "test" variable? or maybe the space is reserved in 1) (?) and it doesn't change.

There is no memory space difference between these two. new test[32] in a function reserves space for 32 elements on the stack (the stack is pre-allocated as well; the compiler estimates the stack usage; it should alloc more than needed, especially if recursion is involved)

new test[32] on the global scope would add 32 cells to the data section.

Zenith77 11-06-2005 11:15

Scratch this...

XxAvalanchexX 11-06-2005 13:56

what?

Xanimos 11-06-2005 14:15

when you use format() the way that you used it, it starts over with 't' as the only char in the string. so now Zenith thats incorrect.

Zenith77 11-06-2005 14:18

whoops, i completly mis understood him, thought ahh nm... to hard to explain...

commonbullet 11-06-2005 14:44

Thank you.


All times are GMT -4. The time now is 23:55.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.