@sentry/browser
@sentry/node
raven-js
raven-node
_(raven for node)_5.5.0
Creating a new issue since #1762 was closed.
There exists a small memory leak in @sentry/node. Calling setTag
with some long strings makes it a lot larger.
This is identifiable because it's not only a memory leak, but according to my DO droplet metrics, it causes a permanent increase in CPU usage & Bandwidth public that can only be fixed by restarting the server.
Pic shows what happens when I added setTag
(July 11) and when I removed it (Aug 9).
Are you able to provide some repro-case for this? setTag
with multiple concurrent requests will for sure increase a memory footprint, but once a scope is GC'd, memory should drop to the baseline.
@kamilogorek the offending code is here: https://github.com/ParabolInc/action/blob/0bde4b002aa3d53fc00f1febcb39185079d827f2/packages/server/utils/sendToSentry.ts#L28-L35
from the looks of it, the scope isn't getting GC'd.
it may be unpopular, but all i really want is a clean API call that takes an exception & variables. e.g. Sentry.captureExpection(error, {tags: {foo: 1}})
. that would get rid of the scopes & associated memory leaks.
withScope
at the end of it's lifecycle performs a popScope
operation which get rid of the layer from the internal array, thus there's no strong reference to it - GC takes care of it automatically.
fwfw you can change your call to:
Sentry.withScope((scope) => {
scope.setUser(user)
scope.setTags(tags)
Sentry.captureException(error)
});
Most helpful comment
@kamilogorek the offending code is here: https://github.com/ParabolInc/action/blob/0bde4b002aa3d53fc00f1febcb39185079d827f2/packages/server/utils/sendToSentry.ts#L28-L35
from the looks of it, the scope isn't getting GC'd.
it may be unpopular, but all i really want is a clean API call that takes an exception & variables. e.g.
Sentry.captureExpection(error, {tags: {foo: 1}})
. that would get rid of the scopes & associated memory leaks.