PDA

View Full Version : #pragma dynamic default value


MP2
24/07/2013, 03:25 AM
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?

Kyle
24/07/2013, 01:33 PM
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.

stock CallStock()
{
if(tester == 1) { CallStock(); }
else { lol(); tester = 1; }
}

Red_Dragon.
24/07/2013, 03:10 PM
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.

MP2
27/07/2013, 03:47 PM
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?

MP2
27/07/2013, 04:17 PM
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.

MP2
27/07/2013, 04:43 PM
I see, thanks.