Posts: 118
Threads: 10
Joined: May 2013
24.01.2016, 16:44
(
Последний раз редактировалось Yousha; 18.09.2017 в 09:28.
)
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 ?
Posts: 10,066
Threads: 38
Joined: Sep 2007
Reputation:
0
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.
Posts: 118
Threads: 10
Joined: May 2013
24.01.2016, 17:48
(
Последний раз редактировалось Yousha; 10.02.2017 в 15:54.
)
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?
Posts: 263
Threads: 11
Joined: Nov 2014
Posts: 4,885
Threads: 57
Joined: Jun 2012
Reputation:
0
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.
Posts: 118
Threads: 10
Joined: May 2013
Thanks, but its not mine...
its for another server, and im just trying to improve/clean it