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
Kiru535Kiru535 

Heap Size Error while running batch class

I am getting Heap size error while running batch class.

Error :
First error: Apex heap size too large: 12020286

I have cleared all the list components...still I am getting this error. Can you please anybody quick reply ASAP for resolution ASAP.
Ramu_SFDCRamu_SFDC
Check the below article and post

http://help.salesforce.com/apex/HTViewSolution?id=000138825&language=en_US

https://developer.salesforce.com/forums/ForumsMain?id=906F00000008ztLIAQ

Kiru535Kiru535
Thanks for your post.....

We do not have that kind of iterations in our code.... Please let me know do I need to do anything otherthan clearing the lists to avoid the heap error.
Arunkumar RArunkumar R
Hi Kiru,

Some of the keypoints to note to avoid this problem,

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.

Please follow this link http://help.salesforce.com/HTViewSolution?id=000004186&language=en_US (http://help.salesforce.com/HTViewSolution?id=000004186&language=en_US) and restructor your code... This will avoid hepsize limit.