easyDialog.inc exceed heap size
#1

Hi to everyone.

I've got a lot of dialog inside OnDialogResponse, so for making order and optimize some code i decide to include easyDialog.
Now here the problem, when i compile without easyDialog it's just fine but only including it and re-compiling i get this warning of heap exceed size:
Code:
Header size:          23580 bytes
Code size:          2241844 bytes
Data size:         39938120 bytes
Stack/heap size:      16384 bytes; estimated max. usage=4100 cells (16400 bytes)
Total requirements:42219928 bytes
If I adapt all my dialog to easyDialog system(emptying OnDialogResponse), I can rid this problem?
Reply
#2

Well, maybe something's driving some of your arrays into higher values which uses more memory. It's not an error. You can try searching for arrays and resize them to a smaller value if it's possible. If not, or if it persists, use #pragma dynamic 20000 or just don't use that include at all.
Reply
#3

Heap/stack size max. usage estimations are based, mostly, on how much depth of function calls your script might fall into. Provided there is no recursion, in which case it'd theoretically be infinite. This happens because each depth requires arguments and returns addresses amongst other data to be added to the stack.

In any case, for SA-MP at least, the correct solution is always to just increase the size of the heap. Do this by adding this preprocessor directive to your script:

#pragma dynamic 16000

This will set your script's heap to 16000 cells, or around 64k bytes. There are no downsides to having too much heap other than meaningless amounts of extra memory usage. If this still worries you for whatever reason you could do 8000 (for 32k bytes)
Reply
#4

Quote:
Originally Posted by Markski
View Post
Heap/stack size max. usage estimations are based, mostly, on how much depth of function calls your script might fall into. Provided there is no recursion, in which case it'd theoretically be infinite. This happens because each depth requires arguments and returns addresses amongst other data to be added to the stack.

In any case, for SA-MP at least, the correct solution is always to just increase the size of the heap. Do this by adding this preprocessor directive to your script:

#pragma dynamic 16000

This will set your script's heap to 16000 cells, or around 64k bytes. There are no downsides to having too much heap other than meaningless amounts of extra memory usage. If this still worries you for whatever reason you could do 8000 (for 32k bytes)
How do you estimate the size? Based on what exactly are the estimations, to set pragma dynamic value?
Reply
#5

Quote:
Originally Posted by Uberanwar
View Post
How do you estimate the size? Based on what exactly are the estimations, to set pragma dynamic value?
If you mean the amount of heap that your script will use in the worst case scenario, the compiler says it here:

Quote:

estimated max. usage=4100 cells (16400 bytes)

Again, this is calculated based on how much function calling depth your script can manage, and how much data would get pushed to the heap with each.

If you mean what #pragma dynamic you should use, the value is in cells. 1 cell is 4 bytes, which is why #pragma dynamic 16000" sets the heap to 64,000 bytes.

Usually I recommend just setting it to 16000 no matter what. It won't break anything, the extra amount of memory usage is meaningless, and it'll make sure you never inadvertly run into any heap overflow issues (unless you do something such as recursion)
Reply
#6

Thank you very much for the help!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)