Troubleshoot 'System.LimitException: Batchable instance is too big' error
If a batch apex class implements Database.Stateful, the instance state is stored in the database. At this time we do a check against the size of the instance state and t he exception is thrown when the Apex Heap Size limit is exceeded. For synchronous Apex the heap size limit is 6 MB and for asynchronous Apex the limit is 12 MB. This exception can obviously occur in a scenario where large collections are persistently maintained. Even if some chunks fail with this error, the batch job is completed. As per below lines in Batch Apex Developer Guide "If the first transaction succeeds but the second fails, the database updates made in the first transaction are not rolled back." To work around this issue, you can use the following steps: 1. Avoid using Database.Stateful 2. Reduce the amount of persistent data 3. Process less records per batch In some cases Database.Stateful isn't being implemented or the steps above are not helpful in working around this e...