Memory questions and #pragma dynamic
#1

Hi

I have some questions about Memory usage, heap/stack, #pragma dynamic and...
(already searched alot, but couldnt find my answer)


1- How much is DEFAULT value of #pragma dynamic?

2- The value of #pragma dynamic must be greater than the value of the estimated maximum usage, so what if someone get: estimated max. usage: unknown, due to recursion ?
Reply
#2

The default stack size is 16 KiB, as can be read in that piece of text you posted. Under normal circumstances there shouldn't be a need to increase the stack size. A normal variable is 4 bytes in size. Variables are pushed onto and popped off the stack as and when they're needed and no longer needed, respectively.

Recursion means that you have one or more functions that call themselves. Each time the function is called it must allocate more space on the stack, while simultaneously keeping everything from the previous call in memory. Since the compiler cannot determine how often a function calls itself, it also cannot determine what the overall stack usage will be.

In general, running out of stack space tells more about the scripter's abilities (or lack thereof) than anything else. I have never needed to add #pragma dynamic to any of my scripts.
Reply
#3

Thanks...
Does #pragma dynamic's value adds on Default stack size? or replaced?

Ex.:
#pragma dynamic 32000
Then my stack size will be: 17kb + 32kb or just 32kb?
Reply
#4

Just 32kb.
Reply
#5

I agree with Vince for me in three years of scripting there has never been a need to use this and if you do then chances are you are doing something wrong.
Reply
#6

Thanks, but its not mine...
its for another server, and im just trying to improve/clean it
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)