Some of my users are experiencing a strange behavior that I can't yet reproduce in a Sandbox, so I'm trying to monitor the bug more closely in our production database.
Since I'm in a production database, I can't edit the code to add new System.debug()
calls. Instead, I'd like to use Heap Dumps to inspect the heap and state at various points, but I can't figure out how to collect them.
I'm monitoring a user's debug logs with the APEX_CODE
filters set to 'Finest'. Logged in as myself, I have the Developer Console open with 2 heap dump locations set. But no heap dumps are captured, even though I can see from the debug logs that the code is being run.
How can I capture these dumps, or do you have other recommended debugging techniques?
Best Answer
The new Tooling API has the
ApexExecutionOverlayAction
object.You could use this to capture the heap dump for the required user.
Specifically, try setting:
ActionScriptType
to 'None'ExecutableEntityId
to the Apex class IdExpirationDate
to some time in the future. Maybe an hour outIsDumpingHeap
to trueIteration
to 1Line
to "The line number of the heap dump marker"ScopeId
to the required UserIdI hacked something together in a .NET to try it out.
Note that this didn't make the Heap Dump Location appear in the developer console for the session owner. I logged in as the target user, but it appears I've broken the developer console for that user:
However, after hitting the dump point you can pull the resulting dump out from the ToolingService using the ApexLog. E.g.