Search code examples
javanashorn

Huge amount of unloaded LambdaForm classes when using Nashorn


I'm building a framework which invokes custom Nashorn scripts which in turn registers Predicates, Comparators etc.

Ie.

function init (context)
{
  context.registerFilter("name", function(item) {
    ... Do some filter of item
  });
}

Then on the Java side I make use of the registered filters. When doing this for a lot of items a long time i'm seeing HUGE amount of unloaded classes of type java.lang.invoke.LambdaForm$DMH/BMH Is this normal, should I be worried to take this into production ?

enter image description here

I've tried different JVM's (1.8 u152, u161, u162) all with the same behavior.


Solution

  • Nashorn generates invokedynamic instruction for every method call, property set/get from JS. LambdaForms are generated by JDK to handle those invokedynamic instructions. You mentioned that those classes are unloaded. Unless you see serious performance problems, you have nothing to worry.