1

I get data from a web Service and and I do some creating and updating of objects with that data. I am get the following error when i try to fetch data.

     Exceeded max size limit of 6000000 

This is where problem

     HttpResponse res = h.send(req);
1

You have exceeded the maximum heap size limit. To handle this you need to reduce your response size. you are making synchronous calls in which we have 6MB Heap size limit. You can also try asynchronous calls in which we have 12MB Limit.

As per Salesforce docs.

The "Apex heap size too large" error occurs when too much data is being stored in memory during processing. The limit depends on the type of execution (E.g. synchronous vs asynchronous calls) and current value can found in limit document.

Some of best practices

  • Don't use class level variables to store a large amounts of data.
  • Utilize SOQL For Loops to iterate and process data from large queries.
  • Construct methods and loops that allow variables to go out of scope as soon as they are no longer needed.

Apex heap size best practices

How to avoid apex heap size error

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.