question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Memory leak in `_contexts`

See original GitHub issue

We upgraded to Node 8 yesterday, and are now seeing memory leaks. Taking some heap snapshots I can see the _contexts map growing all the time. We run 4.2.2, so it shouldn’t be the memory leak fixed recently.

It’s hard to follow the code, but I would guess this is related to how the promises are handled. At least it seems the contexts are not always removed from the map.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:6 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
holmcommented, Nov 8, 2017

We eventually worked out what was causing this. Turned out to actually be the NewRelic that was the main culprit, albeit we also had some of our own.

The fact that the contexts are only destroyed when the promise is garbage collected, requires you to be very careful that you do not in some indirect way reference the promises from the data you store in the cls.

0reactions
clakechcommented, Aug 28, 2017

Hum, seems like, it is a normal behavior in this issue https://github.com/nodejs/node/issues/14446#issuecomment-317673776

so maybe this issue here is OK too.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Context and memory leaks in Android - Medium
Learning to properly manage the Context is an skill that will save us from unexpected problems and that is closely linked with memory...
Read more >
Android : References to a Context and memory leaks
I've read that it is a mistake and a source of memory leaks in Android application to keep a long-lived references to a...
Read more >
Everything You Need To Know About Context-Related ...
Everything You Need To Know About Context-Related Memory Leaks In Android · Step #1. It traverses all the objects from GC roots and...
Read more >
Memory Leaks in Android: Find, Fix, and Avoid
1. You should not: Avoid using static variables for views or context-related references. Pass a context-related reference to a Singleton class. Improperly use...
Read more >
Context- and Path-sensitive Memory Leak Detection∗
We present a context- and path-sensitive algorithm for de- tecting memory leaks in programs with explicit memory management. Our leak detection algorithm is ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found