'OutOfMemoryError: Java heap space' in vfviper-error.log


Overview of the Issue

This issue occurs in the following circumstances:

  1. An organization installs the vFunction Controller with the Viper process started
  2. In the vFunction Server UI, the Controller with Viper running unexpectedly displays a message that, “Status: Viper is down”
  3. On the machine running the Viper process, the /var/log/vfunction/instances/$INSTANCE_NAME/vfviper-error.log shows the following error:
Exception in thread "WS-Resolver::ResourceRepo-Default-Workset" java.lang.OutOfMemoryError: Java heap space
        at java.base/java.lang.StringUTF16.compress(Unknown Source)
        at java.base/java.lang.String.<init>(Unknown Source)
        at java.base/java.lang.String.<init>(Unknown Source)
        at java.base/java.io.DataInputStream.readUTF(Unknown Source)
        at java.base/java.io.DataInputStream.readUTF(Unknown Source)
        at org.apache.bcel.classfile.ConstantUtf8.getInstance(ConstantUtf8.java:155)
        at org.apache.bcel.classfile.Constant.readConstant(Constant.java:89)
        at org.apache.bcel.classfile.ConstantPool.<init>(ConstantPool.java:88)
        at org.apache.bcel.classfile.ClassParser.readConstantPool(ClassParser.java:224)
        at org.apache.bcel.classfile.ClassParser.parse(ClassParser.java:132)
        at org.pfsw.tools.cda.core.dependency.analyzer.AClassFileAnalyzer.parse(AClassFileAnalyzer.java:148)
        at org.pfsw.tools.cda.core.dependency.analyzer.ClassFileAnalyzer.doAnalyze(ClassFileAnalyzer.java:327)
        at org.pfsw.tools.cda.core.dependency.analyzer.AClassFileAnalyzer.analyze(AClassFileAnalyzer.java:69)
        at org.pfsw.tools.cda.core.init.BinaryFileClassInitializer.initializeClass(BinaryFileClassInitializer.java:68)
        at org.pfsw.tools.cda.base.model.ClassInformation.loadIfNecessary(ClassInformation.java:574)
        at org.pfsw.tools.cda.core.init.DependencyResolverTask.processClassInfo(DependencyResolverTask.java:78)
        at org.pfsw.tools.cda.core.init.DependencyResolverTask$$Lambda$743/0x00007f248440faf0.process(Unknown Source)
        at org.pfsw.tools.cda.base.model.ClassPackage.processClassInformationObjects(ClassPackage.java:374)
        at org.pfsw.tools.cda.base.model.GenericClassContainer.processClassInformationObjects(GenericClassContainer.java:307)
        at org.pfsw.tools.cda.base.model.Workset.processClassInformationObjects(Workset.java:822)
        at org.pfsw.tools.cda.core.init.DependencyResolverTask.execute(DependencyResolverTask.java:62)
        at org.pfsw.tools.cda.core.init.AWorksetInitializationTask.run(AWorksetInitializationTask.java:79)
        at java.base/java.lang.Thread.run(Unknown Source)

Steps to Resolve the Issue

This issue can be resolved by taking the following steps:

  1. SSH to the Linux VM
  2. Open the /etc/sysconfig/vfunction/installation/instances/$INSTANCE_NAME/installation.yaml
  3. Under the Viper key, add a subkey which defines the startup memory usage for Viper:
viper:
   jvm_memory_params: "-Xms300m -Xmx2g -Xss50m"
  1. Run the upgrade to apply those settings, restart the processes and try to complete the Static Analysis:
bash /opt/vfunction/controller-installation/upgrade.sh -i $INSTANCE_NAME
  1. If OutOfMemory errors are still thrown, consider increasing the Memory on the machine where Viper runs or installing the Controller on a machine with more available memory