Memory leak while using kieScanner API's in RHDM 7 release.

Solution Unverified - Updated -

Issue

  • Memory Leaks with instances of org.drools.compiler.kie.builder.impl.ZipKieModule everytime a new kjar is generated while using KieScanner API's.
  • Steps to replicate:

1). Instantiate and start a KieScanner instance with version "LATEST".

 String groupId = "com.sample.rules";
 String artifactId = "sampleProject";
 String version = "LATEST";
 KieServices kieServices = KieServices.Factory.get();
 ReleaseId releaseId = kieServices.newReleaseId(groupId, artifactId, version);
 KieContainer kieContainer = kieServices.newKieContainer(releaseId);
 KieScanner kieScanner = kieServices.newKieScanner(kieContainer);
 kieScanner.start(1000L);

You can observe the first KieModule added (1.1.4):

 [main] INFO org.drools.compiler.kie.builder.impl.KieRepositoryImpl - KieModule was added: ZipKieModule[releaseId=com.sample.rules:sampleProject:1.1.4,file=C:\Mave\apache-maven-3.2.5\repository\com\sample\rules\sampleProject\1.1.4\sampleProject-1.1.4.jar

2). Generate 7 new kjars with the same version 1.1.4:

[Timer-0] INFO org.drools.compiler.kie.builder.impl.KieRepositoryImpl - KieModule was added: ZipKieModule[releaseId=com.sample.rules:sampleProject:1.1.4,file=C:\Mave\apache-maven-3.2.5\repository\com\sample\rules\sampleProject\1.1.4\sampleProject-1.1.4.jar]
[Timer-0] INFO org.drools.compiler.kie.builder.impl.KieRepositoryImpl - KieModule was added: ZipKieModule[releaseId=com.sample.rules:sampleProject:1.1.4,file=C:\Mave\apache-maven-3.2.5\repository\com\sample\rules\sampleProject\1.1.4\sampleProject-1.1.4.jar]
[Timer-0] INFO org.drools.compiler.kie.builder.impl.KieRepositoryImpl - KieModule was added: ZipKieModule[releaseId=com.sample.rules:sampleProject:1.1.4,file=C:\Mave\apache-maven-3.2.5\repository\com\sample\rules\sampleProject\1.1.4\sampleProject-1.1.4.jar]
[Timer-0] INFO org.drools.compiler.kie.builder.impl.KieRepositoryImpl - KieModule was added: ZipKieModule[releaseId=com.sample.rules:sampleProject:1.1.4,file=C:\Mave\apache-maven-3.2.5\repository\com\sample\rules\sampleProject\1.1.4\sampleProject-1.1.4.jar]
[Timer-0] INFO org.drools.compiler.kie.builder.impl.KieRepositoryImpl - KieModule was added: ZipKieModule[releaseId=com.sample.rules:sampleProject:1.1.4,file=C:\Mave\apache-maven-3.2.5\repository\com\sample\rules\sampleProject\1.1.4\sampleProject-1.1.4.jar]
[Timer-0] INFO org.drools.compiler.kie.builder.impl.KieRepositoryImpl - KieModule was added: ZipKieModule[releaseId=com.sample.rules:sampleProject:1.1.4,file=C:\Mave\apache-maven-3.2.5\repository\com\sample\rules\sampleProject\1.1.4\sampleProject-1.1.4.jar]
[Timer-0] INFO org.drools.compiler.kie.builder.impl.KieRepositoryImpl - KieModule was added: ZipKieModule[releaseId=com.sample.rules:sampleProject:1.1.4,file=C:\Mave\apache-maven-3.2.5\repository\com\sample\rules\sampleProject\1.1.4\sampleProject-1.1.4.jar]

[Timer-0] INFO org.kie.api.builder.KieScanner - The following artifacts have been updated: {com.sample.rules:sampleProject:1.1.4=com.sample.rules:sampleProject:jar:1.1.4}
[Timer-0] INFO org.kie.api.builder.KieScanner - The following artifacts have been updated: {com.sample.rules:sampleProject:1.1.4=com.sample.rules:sampleProject:jar:1.1.4}
[Timer-0] INFO org.kie.api.builder.KieScanner - The following artifacts have been updated: {com.sample.rules:sampleProject:1.1.4=com.sample.rules:sampleProject:jar:1.1.4}
[Timer-0] INFO org.kie.api.builder.KieScanner - The following artifacts have been updated: {com.sample.rules:sampleProject:1.1.4=com.sample.rules:sampleProject:jar:1.1.4}
[Timer-0] INFO org.kie.api.builder.KieScanner - The following artifacts have been updated: {com.sample.rules:sampleProject:1.1.4=com.sample.rules:sampleProject:jar:1.1.4}
[Timer-0] INFO org.kie.api.builder.KieScanner - The following artifacts have been updated: {com.sample.rules:sampleProject:1.1.4=com.sample.rules:sampleProject:jar:1.1.4}

At this time, we could observe that only 4 instances of "org.drools.compiler.kie.builder.impl.ZipKieModule" are managed, releasing the older instances from memory.

3). Generate 6 new kjars bumping the version from 1.1.5 to 1.1.11:

[Timer-0] INFO org.drools.compiler.kie.builder.impl.KieRepositoryImpl - KieModule was added: ZipKieModule[releaseId=com.sample.rules:sampleProject:1.1.5,file=C:\Mave\apache-maven-3.2.5\repository\com\sample\rules\sampleProject\1.1.5\sampleProject-1.1.5.jar]
[Timer-0] INFO org.drools.compiler.kie.builder.impl.KieRepositoryImpl - KieModule was added: ZipKieModule[releaseId=com.sample.rules:sampleProject:1.1.6,file=C:\Mave\apache-maven-3.2.5\repository\com\sample\rules\sampleProject\1.1.6\sampleProject-1.1.6.jar]
[Timer-0] INFO org.drools.compiler.kie.builder.impl.KieRepositoryImpl - KieModule was added: ZipKieModule[releaseId=com.sample.rules:sampleProject:1.1.7,file=C:\Mave\apache-maven-3.2.5\repository\com\sample\rules\sampleProject\1.1.7\sampleProject-1.1.7.jar]
[Timer-0] INFO org.drools.compiler.kie.builder.impl.KieRepositoryImpl - KieModule was added: ZipKieModule[releaseId=com.sample.rules:sampleProject:1.1.8,file=C:\Mave\apache-maven-3.2.5\repository\com\sample\rules\sampleProject\1.1.8\sampleProject-1.1.8.jar]
[Timer-0] INFO org.drools.compiler.kie.builder.impl.KieRepositoryImpl - KieModule was added: ZipKieModule[releaseId=com.sample.rules:sampleProject:1.1.10,file=C:\Mave\apache-maven-3.2.5\repository\com\sample\rules\sampleProject\1.1.10\sampleProject-1.1.10.jar]
[Timer-0] INFO org.drools.compiler.kie.builder.impl.KieRepositoryImpl - KieModule was added: ZipKieModule[releaseId=com.sample.rules:sampleProject:1.1.11,file=C:\Mave\apache-maven-3.2.5\repository\com\sample\rules\sampleProject\1.1.11\sampleProject-1.1.11.jar]

[Timer-0] INFO org.kie.api.builder.KieScanner - The following artifacts have been updated: {com.sample.rules:sampleProject:1.1.4=com.sample.rules:sampleProject:jar:1.1.5}
[Timer-0] INFO org.kie.api.builder.KieScanner - The following artifacts have been updated: {com.sample.rules:sampleProject:1.1.5=com.sample.rules:sampleProject:jar:1.1.6}
[Timer-0] INFO org.kie.api.builder.KieScanner - The following artifacts have been updated: {com.sample.rules:sampleProject:1.1.6=com.sample.rules:sampleProject:jar:1.1.7}
[Timer-0] INFO org.kie.api.builder.KieScanner - The following artifacts have been updated: {com.sample.rules:sampleProject:1.1.7=com.sample.rules:sampleProject:jar:1.1.8}
[Timer-0] INFO org.kie.api.builder.KieScanner - The following artifacts have been updated: {com.sample.rules:sampleProject:1.1.8=com.sample.rules:sampleProject:jar:1.1.10}
[Timer-0] INFO org.kie.api.builder.KieScanner - The following artifacts have been updated: {com.sample.rules:sampleProject:1.1.10=com.sample.rules:sampleProject:jar:1.1.11}

At this time, we can observe that every new artifact generates a new instance of "org.drools.compiler.kie.builder.impl.ZipKieModule" in heap, and this isn´t released from memory that eventually leading to Out Of Memory Exception.

Environment

  • Red Hat Decision Manager
    • 7.0.0

Subscriber exclusive content

A Red Hat subscription provides unlimited access to our knowledgebase of over 48,000 articles and solutions.

Current Customers and Partners

Log in for full access

Log In