1

We have built a custom functionality where we used call out from aura component the response size is (5.2 MB) which is under limit of 6 MB for synchronous Apex .There after we have parsed the response (Json format) and no error occurred in scratch org . But when we deploy this code component in packaging org with same call out response with same size(5.2 MB) when the same parsing logic execute we get "Heap size " error. is this platform limitation or any technical limitation .

public static returnType methodName(String accountId,String programId){
    String tokendll = accessToken;
    Http http = new Http();
    HttpRequest request = new HttpRequest();
    String requestEndPoint = endpoint for API call;
    request.setEndpoint(requestEndPoint);
    request.setTimeout(120000);
    request.setMethod('GET');
    request.setHeader(CONTENT_TYPE, APPLICATION_JSON);
    request.setHeader(AUTHORIZATION, BEARER + tokendll );
    HttpResponse response = http.send(request);
    String status = String.valueOf( response.getstatusCode());
    Wrapperclass wrapperVal = Wrapperclass.parse(response.getBody());  // from here we are getting “Heap size “ 
    List<Wrapperclass.data> returnValue = new List<Wrapperclass.data>();
    if( status == SUCCESS_CODE ) {            
        returnValue = wrapperVal.data;
    }        
    return returnValue;
}

public class Wrapperclass {
@AuraEnabled
public List<Data> data;    
@AuraEnabled
public String message {get; set;}
@AuraEnabled
public Integer statusCode {get; set;}
   
public class Data {
    @AuraEnabled
    public String id;
    @AuraEnabled
    public String name;
    @AuraEnabled
    public String feild1;
    @AuraEnabled
    public String field2;
    @AuraEnabled
    public String field3;
    @AuraEnabled
    public String field4;
    @AuraEnabled
    public String mfdate;
    @AuraEnabled
    public Price lp;
    @AuraEnabled
    public List<FProducts> Productlist;
}
public class FProducts {
    @AuraEnabled
    public String id;
    @AuraEnabled
    public String url;
}
public class Price {
    @AuraEnabled
    public Double default_Z {get; set;}
    @AuraEnabled
    public String defaultPercentageOf {get; set;}
    @AuraEnabled
    public String minPercentageOf {get; set;}      
    
}       

public static Wrapperclass parse(String json) {
    return (Wrapperclass) System.JSON.deserialize(json, Wrapperclass.class);
}

}

1 Answer 1

1

You can scatter System.debug(Limits.getHeapSize()) calls in your code to see what the platform's count is. Remember the heap could end up holding both the text form of the message and the parsed version of the message so likely at least x2 the message size. And you may have pulled other data onto the heap.

As I understand it, the limits are not always enforced in non-production environments so those environments can AFAIK give a false sense of security.

Worth always having lots of headroom e.g. only use 50% of a governor limit as sizes/numbers typically vary a bit and apparently random and occasional failures are a pain to diagnose.

1
  • Hi Keith C thanks for reply . I have resolved this issue using pagination concept which api response support.
    – Somnath
    Commented Feb 11, 2021 at 12:32

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .