Inspector leaking functions run with Runtime.callFunctionOn

25 views
Skip to first unread message

Ori Shoshan

unread,
Nov 16, 2020, 6:38:23 AM11/16/20
to v8-dev
We're using Runtime.callFunctionOn at a very high rate, and the compiled functions seem to be leaking -- even when using node.js' `global.gc()` or `HeapProfiler.collectGarbage` to manually trigger a full GC before taking a heapdump. Looking at a heapdump, there are many more "(compiled code)" objects which contain the functions passed to callFunctionOn.

I'm reviewing the code for callFunctionOn and the use of a v8::Local seems to suggest that the function should be freed immediately after that C++ scope exits, so I'm confused.

Am I wrong? When would the functions be garbage collected in that case?

Ori Shoshan

unread,
Nov 16, 2020, 6:41:13 AM11/16/20
to v8-dev
I forgot to mention, but we're using the same string as the expression passed to callFunctionOn every time, and merely passing different arguments and objectId each time. We expected the compiled function to be cached and compiled just once (AFAIK there is a compilation cache that uses the source string as the key)
Reply all
Reply to author
Forward
0 new messages