public class HttpCallout{
public static innerResult callout(String endpoint, String type){
innerResult rs = new innerResult();
captureMaxResource(Limits.getHeapSize() , Limits.getCpuTime() , 'before http call' , rs);
Http h = new Http();
HttpRequest req = new HttpRequest();
req.setEndpoint(endpoint); // PDF hosted xml
req.setMethod(type);
HttpResponse res = h.send(req);
captureMaxResource(Limits.getHeapSize() , Limits.getCpuTime() , 'after http call but before parsing' , rs);
rs.result = parserXML( res.getBody() , rs);
captureMaxResource(Limits.getHeapSize() , Limits.getCpuTime() , 'after parsing' , rs);
return rs;
}
public static string parserXML(String xmlStr , innerResult rs){
//parsing of XML
captureMaxResource(Limits.getHeapSize() , Limits.getCpuTime() , 'after xml parsing' , rs);
return null;
}
public static void captureMaxResource(integer heap , integer cpu , string logindex , innerResult rs){
if(rs.maxHeap != null && rs.maxHeap < heap){
rs.maxHeap = heap;
rs.indexmaxHeap = logindex;
}
else{
rs.maxHeap = heap;
}
if(rs.maxCPU != null && rs.maxCPU < cpu){
rs.maxCPU = cpu ;
}
else{
rs.maxCPU = cpu ;
}
}
public class innerResult{
public string indexmaxHeap{get;set;}
public integer maxHeap{get;set;}
public integer maxCPU{get;set;}
public string result{get;set;}
}
}
You have got interesting responses from the stackexchange yet.Execution Governors and Limits: Total heap size Synchronous Limit: 6 MB - Asynchronous Limit: 12 MBand Email services heap size is 36 MB.https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_gov_limits.htmhttp://salesforce.stackexchange.com/questions/162050/apex-heap-size-and-limit-confusion