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
gopi krishna 33gopi krishna 33 

How to overcome JSON string exceeds heap size limit error

Hi Guys,
When i click on custom button it will generate zipfile with attachments which i selected records. Everthing was fine but, if i try more than 4.3 MB it was throwing an error message. Here i used 2 Apex classes not used any visualforce page. I think the problem for apex class as of i queried the body from attachments. If we reduce the body length, may it come.I have been working on this issue for so many days. Could you please solve this issue.

Thanks,
Gopi.
Andy BoettcherAndy Boettcher
Salesforce heap limits are heap limits.  If your use case allows, you could go to Future/Batch APEX which increases the heap limit to 12MB instead of the 6MB you're seeing now.  Keep in mind your heap is all memory allocated by the entire execution path, not just the JSON you're assembling.
gopi krishna 33gopi krishna 33
Hi, In this scenario i used 1 Webservice Class and 1 normal apex class. In webservice class, i wrote return valueswhich are passed to one method which was in same class. From that method return the values to another class. @Future doesn't allow return. Thanks,Gopi. 
shiva chitta 9shiva chitta 9

Hi Mahesh,

im facing the same issue. Need quick help. Please let me how this got resolved?.

Regards,
shiva Chitta
shivachitta@gmail.com
gopi krishna 33gopi krishna 33
Hi Shiva, I couldn't resolve this issue. I found another solution for this scenario. Thanks & Regards,Mahesh.
Alejandro IquiraAlejandro Iquira
Hi Gopi.

Please, can you share your solution for this problem?
gopi krishna 33gopi krishna 33
Hi, I made download the multiple zip files and stored into the local system. Thanks & Regards,Gopi Krishna K.