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
Sridhar Bojja 5Sridhar Bojja 5 

Getting heap size error while deserializing json response in apex

Getting heap size error while deserializing json response in apex

(List<ContractServiceResponseWrapper.Item>)System.JSON.deserialize(JSON.serialize(myMaps), List<ContractServiceResponseWrapper.Item>.class)

 
DevADSDevADS
Hi Sridhar,

Check if you can use future methods with higher limites, please see below for the code reference -
@future(limits='2xHeap')
public static void myFutureMethod() {
    // Your code here
}
OR
Check if the external system can send response in multiple pages.

Do post here if you have any following questions w.r.t the same thread.


 
Kiran kumar.KKiran kumar.K

Hi, Sridhar

 Recently i faced this issue . i got it resolved by writtng a batch class to it.

In Futre class - i am making a callout and formatting the json into Correct Format removing any '//' all those things.

written a queuable class and in there i changed the Json string into a List  and called the batch class -parameters are list<object> jsonstirng. with scope limit 2000.

in the batch class i had the deserailze it as it taken  into chunks  and it is worked Fine.

No heap size error got a log file size of 6.7 mb from 19.1 mb(without using batch).

Do ask if u have any Questions regarding this.