I'm using jBoss Rules.But I run in to memory issues after using JBoss rules. Using a profiling tool I collected heap dump
and I got the result as :
One instance of "org.drools.reteoo.ReteooStatefulSession" loaded by
"sun.misc.Launcher$AppClassLoader # 0x7f899fdb6d88" occupies 657,328,888 (78.91%) bytes.
The memory is accumulated in one instance of "org.drools.reteoo.ReteooStatefulSession"
loaded by "sun.misc.Launcher$AppClassLoader # 0x7f899fdb6d88".
Keywords
sun.misc.Launcher$AppClassLoader # 0x7f899fdb6d88
org.drools.reteoo.ReteooStatefulSession
The code I used for JBoss rules is given below.
kbase= KnowledgeBaseFactory.newKnowledgeBase();
ksession= kbase.newStatefulKnowledgeSession();
final String str = CISMSRemotingUtils.getFullConfigFilePath("change-set.xml") ;
final String filePath = str.replaceAll(" ", "%20");
aconf = KnowledgeAgentFactory .newKnowledgeAgentConfiguration();
aconf.setProperty("drools.agent.newInstance", "false");
kagent = KnowledgeAgentFactory.newKnowledgeAgent( "Agent", aconf);
kagent.applyChangeSet( ResourceFactory.newFileResource(filePath) );
kbase = kagent.getKnowledgeBase();
ksession= kbase.newStatefulKnowledgeSession();
sconf =ResourceFactory.getResourceChangeScannerService().newResourceChangeScannerConfiguration();
sconf.setProperty( "drools.resource.scanner.interval", "3600");
ResourceFactory.getResourceChangeScannerService().configure( sconf );
ResourceFactory.getResourceChangeNotifierService().start();
ResourceFactory.getResourceChangeScannerService().start();
This piece of code is given in the class constructor and rules are fired inside this class
ksession.insert(data);
ksession.fireAllRules();
I'm using drools 5.4.0
Can anyone help me to identify the problem?
Related
im absolutely new to this and struggle with following the tutorial from PyMeshLab (https://pymeshlab.readthedocs.io/en/latest/about.html).
What i want to do:
open a file (e.g. xyz.ply - point cloud) via PyMeshLab
some filter action
save filtered file (e.g. as xyz.obj)
My "code" is stitched together from the tutorias "Load Mesh", "Apply a Filter" and "Save Mesh".
It prompts already a warning when importing the library
import pymeshlab
..
->
Warning:
Unable to load the following plugins:
filter_sketchfab.dll: filter_sketchfab.dll does not seem to be a Qt Plugin.
Cannot load library C:\Users\bvis\AppData\Local\Programs\Python\Python39\lib\site-packages\pymeshlab\lib\plugins\filter_sketchfab.dll: Das angegebene Modul wurde nicht gefunden.
Any ideas?
Thanks
I also get this warning. Still, it seems to work except for print functions like "MeshSet.print_filter_list()", which you might have copied from the example code. You can easily replace the print functions with functions on module level:
import pymeshlab
pymeshlab.print_pymeshlab_version()
filters = pymeshlab.filter_list()
print(filters)
pymeshlab.print_filter_parameter_list('discrete_curvatures')
Results:
PyMeshLab 0.2 based on MeshLab 2020.12d
['alpha_complex_shape', 'ambient_occlusion', 'annulus', 'box_cube', ... 'voronoi_sampling', 'voronoi_scaffolding', 'voronoi_vertex_coloring']
Please note: some parameters depend on the mesh(es) used as input of the
filter. Default values listed here are computed on a 1x1x1 cube
(pymeshlab/tests/sample/cube.obj), and they will be computed on the input mesh
if they are left as default.
surface_reconstruction_screened_poisson filter - list of parameter names:
visiblelayer : bool = False
depth : int = 8
fulldepth : int = 5
cgdepth : int = 0
scale : float = 1.1
samplespernode : float = 1.5
pointweight : float = 4
iters : int = 8
confidence : bool = False
preclean : bool = False
Other MeshSet functions work for me without issues, e.g.:
ms = pymeshlab.MeshSet()
ms.load_new_mesh('test.ply')
ms.apply_filter('discrete_curvatures')
ms.save_current_mesh(output_vis)
I have my groovy script precomplied on server start (I have stored groovy scripts as varchar in DB) up like below in Map ,
final Binding sharedData = new Binding();
final GroovyShell shell = new GroovyShell(sharedData);
script= shell.parse(rs.getString("VALIDATION_SCRIPT"));
Now when checking the validation on input records based on specified validation id i try to execute the precompiled script as below.
Script scrpt = Validation.getScript(); //getting from cache
scrpt.getBinding().setVariable("attributes", objects);
scrpt.getBinding().setVariable("tools", scrpt);
GroovyResponse gr = scrpt.evaluate("tools.valid(attributes)");
but here my application takes long time to evaluate..i guess heap size also gets increase and GC takes place. Can any one help me if there are better way to do it. with out impacting the performance.
one of My groovy script :
import com.fis.derivatives.utility.generic.model.GroovyResponse;
def valid(Map mapInput){
GroovyResponse obj = new GroovyResponse()
if(mapInput.inputVal.equals("1")){
obj.setStatus(true) ;
obj.setResultValue("B") ;
} else if(mapInput.inputVal.equals("2")){
obj.setStatus(true) ;
obj.setResultValue("S") ;
}else{
obj.setStatus(false);
obj.setComment("Error : Unable to extract BUY_SELL. Please check BS value "+mapInput.inputVal+".")
}
return obj;
}
1 - I have doubts about your cache. getting from cache without any key is strange...
Script scrpt = Validation.getScript(); //getting from cache
2 - rework a little the call of groovy:
Script scrpt = Validation.getScript(); //getting from cache
//we will pass attributes as a parameter to method
//scrpt.getBinding().setVariable("attributes", objects);
//not necessary to pass to script link to itself
//scrpt.getBinding().setVariable("tools", scrpt);
GroovyResponse gr = scrpt.invokeMethod​("valid", objects);
this is my objective:
keep the Test Plan more flexible and usable both on win and mac (since some people use mac and other use win).
I created this simple script in groovy:
import org.apache.jmeter.services.FileServer;
import groovy.json.JsonSlurper;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
String winPath;
String macPath;
String winSlash;
String macSlash;
String userPath;
String userSlash;
if (System.properties['os.name'].toLowerCase().contains('windows')) {
winPath="C:\\QA\\";
winSlash="\\";
vars.put("userPath",winPath.toString());
}
if (System.properties['os.name'].toLowerCase().contains('mac')) {
macPath="/Users/macUser/QA/";
macSlash="/";
vars.put("userPath",macPath.toString());
}
and add it into a "JSR223 Sampler" object under my Thread Group object
Then I've added a "User Defined Variables" object with the following var:
Name value
projectDir myProjectDir
rootPath ${__groovy(props.getProperty("userPath"))}${projectDir}
Then I tried to used the rootPath variable for setting the path of my csv files, so I've added ${projectDir}/AUTH.csv to FileName in "CSV Data Set Config" object, but I got this message:
2018-11-23 16:36:40,634 DEBUG o.a.j.t.TestBeanHelper: Ignoring property 'property' in org.apache.jmeter.config.CSVDataSet
2018-11-23 16:36:40,634 DEBUG o.a.j.t.TestBeanHelper: Setting filename=myProjectPath/AUTH.csv
2018-11-23 16:36:40,634 DEBUG o.a.j.t.TestCompiler: Subtracting node, stack size = 2
2018-11-23 16:36:40,634 DEBUG o.a.j.t.TestCompiler: Subtracting node, stack size = 1
2018-11-23 16:36:40,634 INFO o.a.j.t.JMeterThread: Thread started: Thread Group 1-1
2018-11-23 16:36:40,634 INFO o.a.j.s.FileServer: Stored: myProjectPath/AUTH.csv
2018-11-23 16:36:40,635 ERROR o.a.j.t.JMeterThread: Test failed!
java.lang.IllegalArgumentException: Could not read file header line for file myProjectPath/AUTH.csv
as you can see it trying to read myProjectPath/AUTH.csv and then off course it get an exception..
why it doesn't "read" the variable rootPath ?
any suggestions?
According to the User Defined Variables documentation:
Note that all the UDV elements in a test plan - no matter where they are - are processed at the start.
Additionally be aware of JMeter Test Elements Execution Order
0. Configuration elements
1. Pre-Processors
2. Timers
3. Sampler
4. Post-Processors (unless SampleResult is null)
5. Assertions (unless SampleResult is null)
6. Listeners (unless SampleResult is null)
Assuming above points your Groovy code is being executed after User Defined Variables therefore you cannot access the value. So the only way to define dynamic value depending on the operating system in the User Defined Variables is using __groovy() function directly in the Value section like:
${__groovy(if(System.getProperty('os.name').toLowerCase().contains('windows')){return 'C:\\\QA\\\' } else { return '/Users/macUser/QA/' },)}
Make sure to escape commas and backslashes with another backslash as in JMeter Functions comma acts as parameters separator and backslash is an escape character. Check out Apache JMeter Functions - An Introduction guide to learn more about JMeter Functions contept.
The issue is that you try to add it to the properties and try to read it from the variables.
Also, don't bother the \ or / in Java. Java handles both on every platform. (Difference between File.separator and slash in paths)
For me this works fine:
def path;
if (System.properties['os.name'].toLowerCase().contains('windows')) {
path="C:\\QA\\";
} else if (System.properties['os.name'].toLowerCase().contains('mac')) {
path="/Users/macUser/QA/";
}
vars.put("userPath",path);
vars.put("rootPath", path+vars.get("projectDir"));
And to use it: log.info(vars.get("rootPath"))
can anyone enlighten me why the following modelica code generates an error on OpenModelica 1.12.0? If I remove the last two connect equations, it works fine.
class A
Conn cc[3];
Real a(start=0,fixed=true);
Real b(start=0,fixed=true);
Real c(start=0,fixed=true);
equation
der(a) = 1;
der(b) = 2;
der(c) = 3;
connect(a,cc[1].v);
connect(b,cc[2].v); // Remove this to make it work
connect(c,cc[3].v); // Remove this to make it work
end A;
The expandable connector cc is empty:
expandable connector Conn
end Conn;
The code above generates error on OpenModelica 1.12.0:
[1] 15:07:44 Symbolic Error
Too many equations, over-determined system. The model has 6 equation(s) and 4 variable(s).
[2] 15:07:44 Symbolic Warning
[A: 11:3-11:21]: Equation 5 (size: 1) b = cc[2].v is not big enough to solve for enough variables.
Remaining unsolved variables are:
Already solved: b
Equations used to solve those variables:
Equation 2 (size: 1): der(b) = 2.0
[3] 15:07:44 Symbolic Warning
[A: 12:3-12:21]: Equation 6 (size: 1) c = cc[3].v is not big enough to solve for enough variables.
Remaining unsolved variables are:
Already solved: c
Equations used to solve those variables:
Equation 3 (size: 1): der(c) = 3.0
Basically, I want to have an array of expandable connectors which I can add different type of variables as needed.
Edit 18/08/2018
Regarding I can only connect the "connectors" to an expandable connector, actually I see the modelica spec 3.4 doc says:
All components in an expandable connector are seen as connector instances even if they are not declared as
such [i.e. it is possible to connect to e.g. a Real variable].
So it seems I can connect Real variables to an expandable connector in OpenModelica however, I get an error in JModelica:
Error at line 13, column 11, in file 'A.mo':
Connecting to an instance of a non-connector type is not allowed
Also I can connect Real variables to normal (non-expandable) connectors as well in OpenModeica, but again this is not allowed in JModelica. So tools interpret the language specs differently!
You cannot connect Real variables to the expandable connector, it needs to be connectors. But somehow that doesn't work either, seems to be a bug. What works (tested in OM and Dymola) is this below:
class Expandable
expandable connector Conn
Real v[3];
end Conn;
connector RealOutput = output Real "'output Real' as connector";
Conn cc;
RealOutput a(start=0,fixed=true);
RealOutput b(start=0,fixed=true);
RealOutput c(start=0,fixed=true);
equation
der(a) = 1;
der(b) = 2;
der(c) = 3;
connect(a,cc.v[1]);
connect(b,cc.v[2]);
connect(c,cc.v[3]);
end Expandable;
As per ref-doc:
A GroovyClassLoader keeps a reference of all the classes it created, so it is easy to create a memory leak. In particular, if you execute the same script twice, if it is a String, then you obtain two distinct classes!
I use a file as a source for parsing but turned caching off:
GroovyCodeSource src = new GroovyCodeSource( file )
src.cachable = false
Class clazz = groovyClassLoader.parseClass src
Class clazz1 = groovyClassLoader.parseClass src
log.info "$clazz <=> $clazz1 equal: ${clazz == clazz1}"
the log output is always
class MyClass <=> class MyClass equal: false
If I comment the line src.cachable = false, then the class instances become equal, but they are NOT re-compiling even though the underlying file has changed.
Hence the question: how can I re-compile classes properly without creating a memory leak?
i did the following test and don't see any memory leak.
as for me, the normal GC work.
the link to your class will be alive while any instance of class is alive.
GroovyCodeSource src = new GroovyCodeSource( 'println "hello world"', 'Test', '/' )
src.cachable = false
def cl=this.getClass().getClassLoader()
for(int i=0;i<1000000;i++){
Class clazz = cl.parseClass src
if(i%10000==0)println "$i :: $clazz :: ${System.identityHashCode(clazz)}"
}
After doing some experiments, I figured out that switching back to using String:
String src = 'class A {}'
Class clazz = groovyClassLoader.parseClass src
log.info groovyClassLoader.loadedClasses.join( ', ' )
the loaded classes do not change in lenght, even if a class has some Closures inside (which appear as classes as well).