0

We can get heap size being consumed by a method using Limit class. But what if I want to monitor a process and check how it is consuming the memory. e.g. I want to monitor a batch in my org. During every chunk of data execution memory utilization increases and then decreases at the end. Can we track this from outside of it, so that an Admin can check? This resembles the task manager provided by the operating system. Is there any option to find this using BatchId/jobId etc?

2

The Apex Jobs page (under the Setup UI) provides overview information but not to the level of heap usage.

If you want to examine heap usage, the simplest thing to do is to System.debug the Limits.getHeapSize() value. You can then pick a batch size that ensures you are a long way away from the limit.

Or you could make your batchable Database.Stateful, collect the information per execute call and e.g. email the results in the finish method. But that is adding a lot of complexity.

1
  • Thanks, @Keith C, for the idea. But my target is little different. let me give u an example - If you are a windows user, you install an App and use it. To know its performance you go to Task manager and check. You do not edit the App. I am trying to build something like that in our org. A process or something for Admin that can watch other programs - they are mostly batches. So developers can create batches as they want and we are not changing them; rather we want to watch their performance from outside. So, how can we track the running processes? Jan 22 '18 at 5:26
1

This is a cloud platform and salesforce takes care of assigning memory and threads for users in the background. You cannot monitor these things but be rest assured that salesforce is completely capable to handling these things.

You can easily find this out by the number of transactions each POD handles in salesforce trust site.

As long as you write code which executes well within governor limits and following apex coding best practices/bulkification practices you will be fine.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.