NebulaLogger icon indicating copy to clipboard operation
NebulaLogger copied to clipboard

Apex heap size too large during purging after 30 days

Open halderanindya opened this issue 1 year ago • 4 comments

Package Edition of Nebula Logger

Unlocked Package

Package Version of Nebula Logger

V4.12

New Bug Summary

We also use [Nebula Logger Plugin - Big Object Archiving] - Version is 0.9.

We need to retain logs for 30 days so our archiving is set to be 30 days. We get the following error when the framework tries to purge records

caused by: System.LimitException: Apex heap size too large: 13430994

External entry point Class.LogEntryArchiveBuilder.getLogEntryArchive: line 43, column 1 Class.LogEntryArchivePlugin.execute: line 62, column 1 Class.LogBatchPurger.executeApexPlugin: line 275, column 1 Class.LogBatchPurger.executePlugins: line 255, column 1 Class.LogBatchPurger.execute: line 121, column 1

halderanindya avatar Nov 28 '24 13:11 halderanindya

@halderanindya when this error happens, does it cause all subsequent batches to fail? Or does it only cause issues with certain batches within the batch job?

jongpie avatar Dec 16 '24 15:12 jongpie

@jongpie Thanks for looking into this. Yes, all subsequent batches were failing. We then manually deleted the logs.

halderanindya avatar Dec 16 '24 15:12 halderanindya

@halderanindya thanks for the info! In that case, I don't have a quick-fix/workaround for this, but I'll look into it more when I can. Once I have a chance to look at it more, I'll let you know if I have any more questions.

jongpie avatar Dec 16 '24 15:12 jongpie

My original heap size error was larger than yours @halderanindya, and to quickly fix this issue, I had to lower the default batch size in LogBatchPurger to 500.

private static final Integer DEFAULT_BATCH_SIZE = 500;

ERROR Failed to process batch for class 'LogBatchPurger' for job id '707W500001EL44v'

caused by: System.LimitException: Apex heap size too large: 28072473

External entry point Class.LogEntryArchiveBuilder.getLogEntryArchive: line 43, column 1 Class.LogEntryArchivePlugin.execute: line 62, column 1 Class.LogBatchPurger.executeApexPlugin: line 272, column 1 Class.LogBatchPurger.executePlugins: line 252, column 1 Class.LogBatchPurger.execute: line 121, column 1

andrewofornikar avatar Jun 11 '25 12:06 andrewofornikar

I've released a fix for this in release v4.16.3 - the default batch size can now be configured with a new LoggerParameter__mdt record, and it now defaults to 500 out of the box.

If any more issues related to this come up, just let me know!

jongpie avatar Jul 21 '25 21:07 jongpie

@jongpie Thanks for this fix. Awesome stuff as usual!

andrewofornikar avatar Jul 22 '25 07:07 andrewofornikar