what is Heap Size and how to control heap size.
It is in reference to the amount of memory used by the objects. When you create objects in Apex code, as with Java or any standard programming language, memory is allocated to store the objects. And that memory is allocated from the allocated heap.Think of it is a designated amount of memory you can use up in your Apex request.
Limits are for synchronous heap size is 6 MB, for asynchronous it is 12 MB
The "Apex heap size too large" error occurs when too much data is being stored in memory during processing.
Best practices for running within the Apex heap size:
1) Don't use class level variables to store a large amounts of data.
2) Utilize SOQL For Loops to iterate and process data from large queries.
3) Construct methods and loops that allow variables to go out of scope as soon as they are no longer needed.
Limits are for synchronous heap size is 6 MB, for asynchronous it is 12 MB
The "Apex heap size too large" error occurs when too much data is being stored in memory during processing.
Best practices for running within the Apex heap size:
1) Don't use class level variables to store a large amounts of data.
2) Utilize SOQL For Loops to iterate and process data from large queries.
3) Construct methods and loops that allow variables to go out of scope as soon as they are no longer needed.
Comments
Post a Comment