Bug 973168

Summary: Perm gen usage after building KieBase is much higher when compared to drools 5
Product: [Retired] JBoss BRMS Platform 6 Reporter: Petr Široký <psiroky>
Component: BREAssignee: Mario Fusco <mfusco>
Status: CLOSED CURRENTRELEASE QA Contact: Petr Široký <psiroky>
Severity: medium Docs Contact:
Priority: unspecified    
Version: 6.0.0CC: hingoraniviveks, lpetrovi, rrajasek
Target Milestone: ---Keywords: Regression
Target Release: 6.0.0   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2014-08-06 20:15:37 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Attachments:
Description Flags
Perm gen usage comparison - Drools 5 vs Drools 6
none
Simple Maven based reproducer none

Description Petr Široký 2013-06-11 12:13:18 UTC
Created attachment 759593 [details]
Perm gen usage comparison - Drools 5 vs Drools 6

Description of problem:
After creating KieBase, the permanent generation usage is about 50% higher with Drools 6 compared to Drools 5. The KieBase is just built so no KieSessions are being created and used. The number of loaded classes is almost identical in both versions (checked with visualvm).

See the attached simple Maven reproducer and the pdf that compares the perm gen usage for Drools 6 and Drools 5.


Version-Release number of selected component (if applicable):
Drools 6.0.0-Beta3 (and SNAPSHOT after that)
Drools 5.3.x (the exact version is BRMS-5.3.1-P02).


How reproducible:
Always


Steps to Reproduce:
1. Run the attached Maven projects (one is for Drools 5 and one for Drools 6) - just mvn test
2. See the perm gen usage messages that are being printed on stdout.


Actual results:
The perm gen usage in Drools 6 is much higher compared to Drools 5.


Expected results:
The perm gen usage is similar in both Drools 6 and Drools 5.

Comment 1 Petr Široký 2013-06-11 12:18:38 UTC
Created attachment 759602 [details]
Simple Maven based reproducer

Comment 2 Petr Široký 2013-06-11 12:20:26 UTC
Forgot to specify JDK version:
$ java -version
java version "1.7.0_19"
OpenJDK Runtime Environment (fedora-2.3.9.4.fc17-x86_64)
OpenJDK 64-Bit Server VM (build 23.7-b01, mixed mode)

Comment 3 Mario Fusco 2013-07-25 09:34:16 UTC
I cannot reproduce this issue. I am using the JDK

Java(TM) SE Runtime Environment (build 1.7.0_25-b15)
Java HotSpot(TM) Server VM (build 23.25-b01, mixed mode)

running it with the following memory settings:

-XX:MaxPermSize=512M -Xmx1536M

The output of the attached test case with Drools 5 follows:

Permgen usage: 3MiB
Running loop 1
Just to be sure the code is not eliminated: packages=1
KBase building took 56s.
Permgen usage: 68MiB
Running loop 2
Just to be sure the code is not eliminated: packages=1
KBase building took 34s.
Permgen usage: 123MiB
Running loop 3
Just to be sure the code is not eliminated: packages=1
KBase building took 34s.
Permgen usage: 123MiB
Running loop 4
Just to be sure the code is not eliminated: packages=1
KBase building took 32s.
Permgen usage: 123MiB
Running loop 5
Just to be sure the code is not eliminated: packages=1
KBase building took 32s.
Permgen usage: 123MiB
End of the test, after manually calling GC...
Permgen usage: 123MiB

while with Drools 6 (using the latest available snapshot) I got:

Permgen usage: 2MiB
Running loop 1
10:54:41.140 [main] INFO  o.d.c.k.b.impl.KieRepositoryImpl - KieModule was added:MemoryKieModule[ ReleaseId=org.default:artifact:1.0.0-SNAPSHOT]
Just to be sure the code is not eliminated: packages=3
KBase building took 67s.
Permgen usage: 108MiB
Running loop 2
10:55:29.392 [main] INFO  o.d.c.k.b.impl.KieRepositoryImpl - KieModule was added:MemoryKieModule[ ReleaseId=org.default:artifact:1.0.0-SNAPSHOT]
Just to be sure the code is not eliminated: packages=3
KBase building took 28s.
Permgen usage: 108MiB
Running loop 3
10:55:55.665 [main] INFO  o.d.c.k.b.impl.KieRepositoryImpl - KieModule was added:MemoryKieModule[ ReleaseId=org.default:artifact:1.0.0-SNAPSHOT]
Just to be sure the code is not eliminated: packages=3
KBase building took 24s.
Permgen usage: 108MiB
Running loop 4
10:56:20.417 [main] INFO  o.d.c.k.b.impl.KieRepositoryImpl - KieModule was added:MemoryKieModule[ ReleaseId=org.default:artifact:1.0.0-SNAPSHOT]
Just to be sure the code is not eliminated: packages=3
KBase building took 24s.
Permgen usage: 108MiB
Running loop 5
10:56:45.289 [main] INFO  o.d.c.k.b.impl.KieRepositoryImpl - KieModule was added:MemoryKieModule[ ReleaseId=org.default:artifact:1.0.0-SNAPSHOT]
Just to be sure the code is not eliminated: packages=3
KBase building took 23s.
Permgen usage: 108MiB
End of the test, after manually calling GC...
Permgen usage: 108MiB

This means that Drools 5 uses 123M while 6 only needs 108M.

Comment 4 Petr Široký 2013-07-25 10:22:35 UTC
I just reran the tests with current SNAPSHOT and the issue is indeed gone. As pointed by Mario, is has been probably fixed between beta3 and beta4 when new Classloader was introduced.

Closing as fixed.

Comment 8 Lukáš Petrovický 2014-02-07 16:15:08 UTC
This BZ has been part of the 6.0.0 stream.

Comment 9 Vivek Hingorani 2015-07-14 05:36:50 UTC
I am getting the same problem in my current project and I am using drools 6.1.0.Final version. I am assuming the above problem will be fixed in Drools 6.1.0.Final version but I am getting the same problem :( 

Any help would be much appreciated.