[jboss-jira] [JBoss JIRA] (DROOLS-1354) Drools PermGen OOM When create kiebulider several times

Shukang Guo (JIRA) issues at jboss.org
Fri Nov 4 05:36:02 EDT 2016


     [ https://issues.jboss.org/browse/DROOLS-1354?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Shukang Guo updated DROOLS-1354:
--------------------------------
    Steps to Reproduce: several times after execute refresh()


> Drools PermGen OOM When create kiebulider several times
> -------------------------------------------------------
>
>                 Key: DROOLS-1354
>                 URL: https://issues.jboss.org/browse/DROOLS-1354
>             Project: Drools
>          Issue Type: Bug
>          Components: core engine
>    Affects Versions: 6.4.0.Final
>         Environment: Windows7 Tomcat7 JDK1.7 
>            Reporter: Shukang Guo
>            Assignee: Mario Fusco
>
> When i need updating the rule , first i will delete it from kieFileSystem , then add it .Second i will create a new KieBuilder and buildAll().But after several time i have done , it would be gone by PermGen OOM.
> {code:java}
> 	@Autowired
> 	private RuleService ruleService;
> 	private KieServices ks = KieServices.Factory.get();
> 	private KieFileSystem kFileSystem = ks.newKieFileSystem();
> 	private KieContainer kContainer;
> 	private KieBase kieBase;
> 	private KieBuilder kbuilder;
> 	private String defaultPath;
> 	/*
> 	 * (non-Javadoc)
> 	 * 
> 	 * @see com.huawei.datalifecycle.rules.RunRuless#init(java.lang.String[])
> 	 */
> 	@Override
> 	@PostConstruct
> 	public void init() {
> 		List<Rule> rules = new ArrayList<>();
> 		rules.add(ruleService.selectById(15));
> 		// List<Rule> rules = ruleService.selectAll(0, 0);
> 		String[] paths = new String[rules.size()];
> 		for (int i = 0; i < paths.length; i++) {
> 			paths[i] = rules.get(i).getPath();
> 		}
> 		init(paths);
> 	}
> 	public void init(String[] paths) {
> 		boolean isSetDefaultPath = false;
> 		for (String path : paths) {
> 			if (isSetDefaultPath)
> 				kFileSystem
> 						.write(ks.getResources().newClassPathResource(path));
> 			else {
> 				Resource resource = ks.getResources().newClassPathResource(
> 						path);
> 				kFileSystem.write(resource);
> 				defaultPath = resource.getResourceType().getDefaultPath() + "/";
> 				isSetDefaultPath = true;
> 			}
> 		}
> 		kbuilder = ks.newKieBuilder(kFileSystem);
> 		kbuilder.buildAll();
> 		kContainer = ks.newKieContainer(ks.getRepository()
> 				.getDefaultReleaseId());
> 		kieBase = kContainer.getKieBase();
> 	}
> 	/*
> 	 * (non-Javadoc)
> 	 * 
> 	 * @see com.huawei.datalifecycle.rules.RunRuless#refresh(java.lang.String)
> 	 */
> 	public void refresh() {
> 		kbuilder = ks.newKieBuilder(kFileSystem);
> 		kbuilder.buildAll();
> 		kContainer.updateToVersion(ks.getRepository().getDefaultReleaseId());
> 	}
> 	/*
> 	 * (non-Javadoc)
> 	 * 
> 	 * @see com.huawei.datalifecycle.rules.RunRuless#getKieSession()
> 	 */
> 	@Override
> 	public KieSession getKieSession() {
> 		return kieBase.newKieSession();
> 	}
> 	@Override
> 	public void add(String path) {
> 		kFileSystem.write(ks.getResources().newClassPathResource(path));
> 		refresh();
> 	}
> 	@Override
> 	public void delete(String path) {
> 		kFileSystem.delete(defaultPath + path);
> 		refresh();
> 	}
> 	@Override
> 	public void update(String path) {
> 		kFileSystem.delete(defaultPath + path);
> 		kFileSystem.write(ks.getResources().newClassPathResource(path));
> 		refresh();
> 	}
> {code}



--
This message was sent by Atlassian JIRA
(v7.2.3#72005)


More information about the jboss-jira mailing list