Memory usage with elastic-apm-node and custom transactions


We have started to use APM and elastic-apm-node to instrument our node application. We get a lot of great information from the express routes which has helped us a lot.

We have recently started to track background jobs as well using custom transactions, but there seems to be an issue with memory never being released when a custom transaction is closed. The application will continue to consume memory until it is out of memory and the application is restarted. The background jobs typically runs for a couple of minutes and generate some 200 spans, so I expect some additional memory usage. But when the transaction is closed I would assume the the memory is released.

We start a custom transaction like this:

import * as APM from "elastic-apm-node";

const trans = APM.startTransaction("JobName", "Job");
try {
  await CacheRunner._runJob(taskDef, task.params);
} catch (err) {
  trans.result = 500;
  throw err;
trans.result = 200;

Which version of the agent are you using?

We just released version 1.2.1, which a fix for a memory leak related to the V8 microtask queue.

I was running 1.1.1. I've tested again using the latest 1.2.1 which completely fixes the issue.
Thanks for your quick reply.

1 Like

This topic was automatically closed 20 days after the last reply. New replies are no longer allowed.