When do the internals of a JSContext get garbage collected?

540 Views Asked by At

I'm using a JSContext in my app, which is working well, but I'm a little concerned about the memory usage. When I've finished using the context, it still sits in my Safari develop menu as a debug target, and when I run "Debug Memory Graph" a lot of JavaScriptCore objects are hanging around.

Is this to be expected (i.e. it gets recycled in the future, as necessary), or is it a sign that I have a memory leak going on? The memory graph doesn't show any, but something must be holding onto those JavaScriptCore objects.

1

There are 1 best solutions below

0
On BEST ANSWER

It turns out that even when you request garbage collection on a JSContext it still doesn't actually (necessarily) do it. You need to use an internal method to force it:

https://stackoverflow.com/a/35904068