[
http://jira.jboss.com/jira/browse/JBIDE-1105?page=comments#action_12394448 ]
Snjezana Peco commented on JBIDE-1105:
--------------------------------------
In order to reproduce this issue, you can use the following test case:
- show heap status
- create a Seam project
- add all the files from
http://jira.jboss.com/jira/secure/attachment/12315941/JBIDE-675.tar.gz to the WebContent
directory
- open employee.xhtml
- press Enter at the end of line 21
Repeating the last step will be increasing memory usage permanently.
There are three issues related to editing that cause OOM in the VPE editor:
1) The VpeVisualDomBuilder.createTextNode() works correctly if it is called the first time
(from the buildDom method).
However, if it is called when updating some element (key press), it creates empty text
nodes for included files.
This causes a memory leak when editing. In order to fix the issue, the method needs to
look as follows:
protected nsIDOMNode createTextNode(Node sourceNode, boolean registerFlag) {
String sourceText = sourceNode.getNodeValue();
if (sourceText.trim().length() <= 0) {
if (registerFlag)
registerNodes(new VpeNodeMapping(sourceNode, null));
return null;
}
...
2) The VpePageContext.setTaglib() method creates more TaglibData objects (for all the tags
in the included files) because the TaglibData class doesn't have equals/hashCode
methods defined correctly. The fix includes the following:
- equals/hashCode in the TaglibData class taking into consideration all the fields except
the id field.
- changing this method as follows :
if (newUri != null && newPrefix != null) {
TaglibData data = new TaglibData(id, newUri, newPrefix, ns);
if (!taglibs.contains(data)) {
taglibs.add(data);
rebuildTaglibMap();
}
}
3) The most important part and the main cause of OOM
The VpeInlcudeTemplate.create method calls VpeCreatorUtil.getDocumentForRead(file,
pageContext) that opens a document for reading.
The VPE editor immediately calls the VpeIncludeTemplate.validate method that closes the
document for reading.
This happens on every key press. The problem is that opening the document caches a lot of
xml classes (about 500000 for employee.xhtml), but closing it doesn't clear them.
Every opening/closing (keypress) some include document allocates a new cache and VPE
throws OOM very quickly.
The solution is to open documents for reading, remember them and not to close them until
the editor is closed.
I have tried this (the documents are remembered in VpeVisualDomBuilder). Editing is much
faster and, what is more important, VPE doesn't throw the OOM exception.
Memory usage isn't increased when editing.
The attached patch includes the patch from JBIDE-538.
OutOfMemoryException when many ui:includes
------------------------------------------
Key: JBIDE-1105
URL:
http://jira.jboss.com/jira/browse/JBIDE-1105
Project: Tools (JBoss Tools)
Issue Type: Bug
Components: Visual Page Editor
Affects Versions: 2.0.0.CR1
Reporter: Max Andersen
Assigned To: Sergey Vasilyev
Priority: Critical
Fix For: 2.1
See duplicate issue for info on how to reproduce
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://jira.jboss.com/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira