Max string size
#1

does anyone know what max length of a string is in pawn?
Reply
#2

I don't believe there is one to be exact, but obviously something crazy like 3000 would be too much? I always use 258.
Reply
#3

1 string cell is 4 bytes, so as many increments of 4 bytes go nearest to your available system memory.

My system has 2048mb of RAM, so in bytes that's 2,048,000,000 bytes, divide it by 4 = 512,000,000 - so theoretically that's the largest string I can make on my system.

I don't think there are any Pawn limits, just system memory limits, then again I've never really been good with math or VM architecture.

Reminder to other posters: This thread is asking about the maximum size possible, not your opinion on what the maximum should be used.
Reply
#4

I recommend using string lengths between 50 to 128.
Reply
#5

Quote:
Originally Posted by Jack_Leslie
Посмотреть сообщение
I don't believe there is one to be exact, but obviously something crazy like 3000 would be too much? I always use 258.
Uh oh, you should always use 128 over 256. I don't have an opinion on this, other than I've seen in some game-modes strings up to 5000, for things like files, etc. Obviously if you're using strings for things like textdraws there is a limit of 1024.
Reply
#6

yeah, i've heard about people freaking about 256 and stuff and i know thats all bull, i just didn't know if there was a hardcoded limit, thanks guys

Edit: i had my debug setup on a command, tried to create a variable of 4096, the debug messages stopped there so I'm assuming that 4096 would not work.
Reply
#7

Quote:
Originally Posted by Famalamalam
Посмотреть сообщение
Uh oh, you should always use 128 over 256. I don't have an opinion on this, other than I've seen in some game-modes strings up to 5000, for things like files, etc. Obviously if you're using strings for things like textdraws there is a limit of 1024.
It depends completely on how big the string you're going to use is going to be. Just because you're making a new array doesn't mean you should automatically assign it to 128 cells. If you know a string is not going to be over 30 units, you would make it 30 cells.

Anyway, I looked through the pawn_lang.pdf and other documents. I couldn't find any limits.
Reply
#8

Global variables gets saved in the amx file => unlimited, or your harddrive memory
Local variables gets dynamicly allocated in the stack / heap memory block which is normally 16 kb big (4096 cells - heap information)
Although you can increase this memory block with #pragma dynamic <cells>

If its near the collision point of the stack and the heap this warning will appear
Quote:
Originally Posted by pawncc.exe
Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase

Header size: 88 bytes
Code size: 196 bytes
Data size: 44 bytes
Stack/heap size: 16384 bytes; estimated max. usage: unknown, due to recursion
Total requirements: 16712 bytes
If it rly collides than you will get this message if you execute your script
Quote:
Originally Posted by server_log.txt
Script[gamemodes/stack.amx]: Run time error 3: "Stack/heap collision (insufficient stack size)"
Reply
#9

Quote:
Originally Posted by Nero_3D
Посмотреть сообщение
Global variables gets saved in the amx file => unlimited, or your harddrive memory
Local variables gets dynamicly allocated in the stack / heap memory block which is normally 16 kb big (4096 cells - heap information)
Although you can increase this memory block with #pragma dynamic <cells>

If its near the collision point of the stack and the heap this warning will appear


If it rly collides than you will get this message if you execute your script
Thank you for the clarification, I really ought to fully read pawn*.pdf.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)