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
Ketan Solanki29Ketan Solanki29 

Can we devide list of Sobject into several list

I have Trigger on Before Insert event Dummy Transaction object which creating list of Transaction object after processing the all Dummy Transaction.

dut to large data load into the Dummy Transaction object i am getting "System.LimitException: Apex heap size too large:" error at the line where i am inserting the list of transaction object. there is also After Insert trigger on Transaction object so when large list is inserted i am getting this error.

 

like :

       INSERT txList;

 

txList is list of Transaction object which is created from the Dummy Transaction trigger.

 

Is there any way so we can split list into several list and then Insert the list one by one.so the error is not generated.

SeAlVaSeAlVa

I believe that heap size problem is caused because.

- you are in the trigger and insert

- what triggers your trigger that, again, inserts more records

- what triggers your trigger that, again, inserts more records, 

- what....

 

with no end. I believe that is why you hit heap size limit (you are calling your-self recursively over and over again.

 

Have a look at your code and 

a) change your logic (might be wrong coded)

b) create a static flag that allow you to stop when you want.

 

Regards.