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

Mario Fusco (JIRA) issues at jboss.org
Wed Sep 19 10:26:00 EDT 2018


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

Mario Fusco resolved DROOLS-1354.
---------------------------------
    Resolution: Out of Date


> 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)
> 	 */
> 	@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)
> 	 */
> 	public void refresh() {
> 		kbuilder = ks.newKieBuilder(kFileSystem);
> 		kbuilder.buildAll();
> 		kContainer.updateToVersion(ks.getRepository().getDefaultReleaseId());
> 	}
> 	/*
> 	 * (non-Javadoc)
> 	 */
> 	@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.5.0#75005)


More information about the jboss-jira mailing list