JDK-8229011: Hints
STAMPF Lukas
lukas.stampf at bat.at
Thu Jul 2 18:00:48 UTC 2020
Hello,
I hope I don't bother anyone with this.
Out of curiosity I looked into this and it seems that the LambdaForms, MethodHandles, etc created by the DynamicLinker are nerver garbage collected. Before
https://bugs.openjdk.java.net/browse/JDK-8141538
this wasn't so bad, because there was always just one static DynamicLinker, therefore the amount of leaking objects was limited. With this change, there is one DynamicLinker per Context(so on per ScriptEngine) creating a memory leak.
This can be shown by adding
if (linker == null)
{
linker = getLinker(scriptEngine);
}
setLinker(scriptEngine, linker);
to the loop in the testcript linked in Jira. Set/getLinker are simply using reflection to get/set the final field of jdk.nashorn.internal.runtime.Context dynamicLinker.
The question I can't answer yet is why the Objects created by the DynamicLinker are not garbage collected. JProfiler and Eclipse MAT seem to be unable to analyze these dynamic objects properly. Most of the objects are marked as unreachable but not collected.
I would be grateful for every input on why it could be this way or what I could try to find out whats keeping these unreachable objects alive.
Kind regards,
Lukas
More information about the nashorn-dev
mailing list