chakra-core / chakra-core/ChakraCore

Memory leak in JsSetCurrentContext

Open
#5,017 12 comments 0 reactions 0 assignees View on GitHub
Bug Linux Severity: 3
Dominant language
JavaScript
Stars
9.3k
Forks
1.2k
PR merge metrics
No merged PRs in 30d

Description

Hi folks,

I've noticed that `JsSetCurrentContext` seems to leak small amounts of memory; see the screenshot below for a backtrace from Instruments on macOS. We're using ChakraCore in a server process, and during stress testing yesterday I noticed that we were leaking memory. Instruments shows that `JsSetCurrentContext` calls appear to be the cause; all roads lead to `ThreadContextTLSEntry` in the backtraces.

Is it possible that there's some required cleanup that I'm missing here? In our current design, request threads "borrow" a runtime from a pool, so we end up calling `JsSetCurrentContext` at least once per request. Are we supposed to "un-set" the context when a thread is finished using a runtime?

![image](https://user-images.githubusercontent.com/512212/39010464-964e0426-43c3-11e8-980d-2b4eb6a541d3.png)

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.