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
Tanner RussellTanner Russell 

Total heap Size limit help

I need help with modifying my code to work around the heap size limit I have tried using @future but it seems to be having issues with my callout session ID can anyone give me tips on how this can be worked around with this code?
public class TransferLiveData {
    
    public static void TransferData(Boolean IsCreate, String resourceName, String ContentT, String CacheCont){
        //create a list to hold the object maps
        List<Map<id,sObject>> masterList = new List<Map<id,sObject>>();
        //convert each query results from List<sObject> to Map<id,sObject> 
        //using query util library to pull all fields
        masterList.add(new Map<id,sObject>(QueryUtil.QueryAllLimit(Account.getSObjectType().getDescribe(), 'limit 25')));
        masterList.add(new Map<id,sObject>(QueryUtil.QueryAllWhereIN(Space__c.getSObjectType().getDescribe(), 'Account__c', masterList[0].keySet())));
        masterList.add(new Map<id,sObject>(QueryUtil.QueryAllWhereIN(Contact.getSObjectType().getDescribe(), 'Accountid', masterList[0].keySet())));
        masterList.add(new Map<id,sObject>(QueryUtil.QueryAllWhereIN(Case.getSObjectType().getDescribe(), 'Space__c', masterList[1].keySet())));
        masterList.add(new Map<id,sObject>(QueryUtil.QueryAllWhereIN(Asset.getSObjectType().getDescribe(), 'Space__c', masterList[1].keySet())));
        masterList.add(new Map<id,sObject>(QueryUtil.QueryAllWhereIN(Lease__c.getSObjectType().getDescribe(), 'Space__c', masterList[1].keySet())));
        masterList.add(new Map<id,sObject>(QueryUtil.QueryAllWhereIN(Opportunity.getSObjectType().getDescribe(), 'Accountid', masterList[0].keySet())));
        masterList.add(new Map<id,sObject>(QueryUtil.QueryAllWhereIN(Contract.getSObjectType().getDescribe(), 'Accountid', masterList[0].keySet())));
        masterList.add(new Map<id,sObject>(QueryUtil.QueryAll(Location__c.getSObjectType().getDescribe())));
        masterList.add(new Map<id,sObject>(QueryUtil.QueryAll(Lead.getSObjectType().getDescribe())));
        
        //serialize the the json
        String jsonDump = JSON.serialize(masterList);
        
        //is this going to be a new static resource or an update
        if(IsCreate){
            MetadataServiceExamples.createStaticResource(resourceName, ContentT, CacheCont, jsonDump);
        }else{
            MetadataServiceExamples.updateStaticResource(resourceName, ContentT, CacheCont, jsonDump);


        }
        
       
        
    }
}