3

I don't understand the importance of heap size limit of 6MB. So could someone help me understand the heap size limit?

2

The 6 million bytes of space for the objects that your code has in memory at once time is sufficient for the vast majority of code to work. You are only likely to exceed that space requirement and so get a governor limit exception if your code is doing something relatively unusual such as trying to hold a very large number of objects in a list or map all at once. Often such code is unintentional, and the governor limit protects other users from suffering performance degradation because of that unintentional code. Occasionally the governor limit does get in the way of legitimate code and can be more frustrating to live with.

You can see how much of the heap your code is consuming by adding e.g.:

System.debug('>>> heap=' + Limits.getHeapSize());

at various points in your code and looking for that output in the debug log. Usually your code will be a very long way away from hitting the limit.

| improve this answer | |
0

All governor limits are put in place to limit the amount of server resources that one tenant can consume in a cloud-based multi-tenant architecture. Heap size is a direct measure of CPU resources for a given server and therefore an ideal proxy for what you are consuming as a tenant.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.