function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
mits430xmits430x 

Estimated heap memory size

Hi all,

Can we estimate how much heap memory Apex may use?
We want to avoid exceeding governor limits as much as possible.
Therefore, we're wondering how to calculate required heap memory before we execute them...

 

 

Does anyone have any idea?

sornasorna

To measure the heap size, there are 2 limit methods available in apex:-

      - getHeapSize()

      - getLimitHeapsize()

Use the first one to measure how much heap size has been used and the second one to know how much can be used. For more information, please refer apex language reference page no. 278.

Regards,

mits430xmits430x
Thanks for your response.

According to those document you pointed, probably the 2 methods are not purpose to forecast heap size, and I could find no info about forecasting it.
It pains me to say it, but did you say there is no ways to forecast without executing Apex?


Thank you.