SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help

Reply
 
Thread Tools Display Modes
Old 28/01/2020, 03:02 PM   #1
pollo97
Big Clucker
 
pollo97's Avatar
 
Join Date: Sep 2011
Location: Italy
Posts: 83
Reputation: 4
Default easyDialog.inc exceed heap size

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?
pollo97 is offline   Reply With Quote
Old 30/01/2020, 02:54 PM   #2
Meric
Little Clucker
 
Join Date: Dec 2019
Posts: 12
Reputation: 0
Default Re: easyDialog.inc exceed heap size

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.
Meric is offline   Reply With Quote
Old 30/01/2020, 09:07 PM   #3
Markski
Big Clucker
 
Markski's Avatar
 
Join Date: Apr 2015
Location: La Plata, Argentina
Posts: 133
Reputation: 59
Default Re: easyDialog.inc exceed heap size

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)
Markski is offline   Reply With Quote
Old 31/01/2020, 07:12 AM   #4
Uberanwar
Gangsta
 
Uberanwar's Avatar
 
Join Date: May 2012
Location: Malaysia
Posts: 893
Reputation: 63
Default Re: easyDialog.inc exceed heap size

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?
Uberanwar is offline   Reply With Quote
Old 31/01/2020, 12:41 PM   #5
Markski
Big Clucker
 
Markski's Avatar
 
Join Date: Apr 2015
Location: La Plata, Argentina
Posts: 133
Reputation: 59
Default Re: easyDialog.inc exceed heap size

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)
Markski is offline   Reply With Quote
Old 01/02/2020, 02:26 PM   #6
pollo97
Big Clucker
 
pollo97's Avatar
 
Join Date: Sep 2011
Location: Italy
Posts: 83
Reputation: 4
Default Re: easyDialog.inc exceed heap size

Thank you very much for the help!
pollo97 is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Heap Size help (+rep) NickMirra Scripting Help 1 22/08/2015 11:11 PM
Stack/Heap Size RayC Scripting Help 2 02/01/2015 03:51 PM
[Help] Stack/heap size David (Sabljak) Scripting Help 3 17/11/2013 03:47 PM
Stack/heap size thimo Scripting Help 2 11/08/2013 09:54 PM
Stack/heap size Azazelo Scripting Help 2 05/11/2012 07:52 PM


All times are GMT. The time now is 09:03 AM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.