#pragma dynamic default value - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: #pragma dynamic default value (
/showthread.php?tid=453179)
#pragma dynamic default value -
MP2 - 24.07.2013
What is #pragma set to by default? Couldn't find any info on it in pawn-lang.pdf. Is it dependent on how much estimated memory you need? If so, why does the 'recursion warning' thing even exist?
Re: #pragma dynamic default value -
Kyle - 24.07.2013
4000-5000 is the default value AFAIK, was discussed recently on the IRC channel.
I have around 10k for my server, if you require the GPS plugin it requires a massive number, if you check the GPS thread tutorial it is in there somewhere.
The recursion warning calls when there is something like this:
Something where it will call the same stock again and again etc.
So basically, it is where the same function gets called within the same function.
Quote:
stock CallStock()
{
if(tester == 1) { CallStock(); }
else { lol(); tester = 1; }
}
|
Re: #pragma dynamic default value -
Red_Dragon. - 24.07.2013
As far as I know, the value of #pragma dynamic must be greater than the value of the estimated maximum usage (to remove the recursion warning). In my script, I have it 10k.
Re: #pragma dynamic default value -
MP2 - 27.07.2013
Quote:
Originally Posted by Red_Dragon.
As far as I know, the value of #pragma dynamic must be greater than the value of the estimated maximum usage (to remove the recursion warning). In my script, I have it 10k.
|
I know that, I'm just wondering what it's set to by default. Clearly the compiler works out how much memory might be needed, so I guess that is how much is allocated? But when recursion becomes a factor, you get that warning in the compiler box and then you have to increase the dynamic memory allocation (with #pragma dynamic) to get rid of it. Why can't (or doesn't) the compiler just do this anyway?
Re: #pragma dynamic default value -
MP2 - 27.07.2013
Quote:
Originally Posted by ******
Because when you have recursion there is no way for the compiler to know what the highest stack value will be. Recursion is when a function calls itself, so if a function can call itself forever your stack will grow forever.
|
But after increasing it enough with #pragma dynamic, the warning no longer shows - why can't the compiler just do this itself? I know it doesn't know how much memory is needed, but clearly at some point it thinks there's enough, because the warning goes away.
Re: #pragma dynamic default value -
MP2 - 27.07.2013
I see, thanks.