This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 123995 - RaveRenderedDocument.userData memory leak
Summary: RaveRenderedDocument.userData memory leak
Status: RESOLVED FIXED
Alias: None
Product: obsolete
Classification: Unclassified
Component: visualweb (show other bugs)
Version: 6.x
Hardware: All All
: P1 blocker (vote)
Assignee: Peter Zavadsky
URL:
Keywords: PERFORMANCE
Depends on:
Blocks: 123530
  Show dependency tree
 
Reported: 2007-12-14 00:29 UTC by Quy Nguyen
Modified: 2008-01-14 22:56 UTC (History)
1 user (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Quy Nguyen 2007-12-14 00:29:45 UTC
There seems to be a cumulative memory leak in the objects stored in the RaveRenderedDocument.userData table. 
RaveSourceDocument, FacesDesignBean, DesignBeanNode, etc. leak from this table.  To reproduce:

1) Create a VW project
2) Drop a button component on Page1
3) Deploy
4) Delete the button component.
5) Deploy
6) Repeat steps 2-4

Memory usage gradually increases with each deployment (which forces a FacesModel.sync() operation).
Comment 1 Quy Nguyen 2007-12-14 00:31:02 UTC
The step 6 should be "Repeat steps 2-5".
Comment 2 Peter Zavadsky 2008-01-02 16:06:21 UTC
There is a link from rendered document to source document. The link seems to be, is not removed, and should be made
weak. I'm going to look at that.
Comment 3 Peter Zavadsky 2008-01-02 19:34:46 UTC
Well, now I was thinking about it, and the previous comments don't sound correct.
This seems to be about accumulating link to the DesignBeanNode (or DesignBean). Need to investigate.
Comment 4 Peter Zavadsky 2008-01-03 22:47:05 UTC
So far discovered one leak in DnDHandler, recentDropTargetComponentRootElement field.
Going to fix that one first.

Didn't discover leak in the RaveRenderedDocument user data yet, it doesn't hold the RaveSourceDocument there (not
directly), the link is maintained by the FacesModel(MarkupUnit).
Will continue after finish the above fix.
Comment 5 Peter Zavadsky 2008-01-03 23:55:41 UTC
Yes, it seems the problem is impl of the org.w3c.dom.Document.userData... it is implemented by HashTable, and it seems
that it doesn't clear it for elements which are removed from the document.
Comment 6 Peter Zavadsky 2008-01-04 00:05:04 UTC
Yes, it seems the problem is impl of the org.w3c.dom.Document.userData... it is implemented by HashTable, and it seems
that it doesn't clear it for elements which are removed from the document.
Comment 7 Peter Zavadsky 2008-01-04 00:51:31 UTC
Also problem is that the UserDataHandler.handle methods don't seem to get called (especially when removed the elements).
Comment 8 Peter Zavadsky 2008-01-04 22:52:14 UTC
Well, it seems that the userData impl of the apache dom Document leak, and there doesn't seem to be a way to fix it from
our subclass.
Thinking about, whether to avoid usage of the userData, and rather maintain individual maps.
Comment 9 Peter Zavadsky 2008-01-04 22:53:23 UTC
To clear up the things, it is not RaveRenderedDocument.userData field (there is no such), but CoreDocumentImpl.userData
field.
Comment 10 Peter Zavadsky 2008-01-05 01:07:27 UTC
Fixed.
Note, there are also other usages of userData, which I need to get rid of, but those shouldn't affect this issue.

Checking in visualweb/insync/src/org/netbeans/modules/visualweb/insync/markup/MarkupUnit.java;
/cvs/visualweb/insync/src/org/netbeans/modules/visualweb/insync/markup/MarkupUnit.java,v  <--  MarkupUnit.java
new revision: 1.10; previous revision: 1.9
done
Comment 11 Quy Nguyen 2008-01-08 01:42:35 UTC
The memory leak still occurs from RaveRenderedDocument->RaveSourceDocument.  To reproduce:

1) Create vw project
2) Drop some component onto Page1.jsp
3) Clean-Build
4) Remove some components from the page or drop additional ones
5) Repeat 3-4
Comment 12 Peter Zavadsky 2008-01-08 16:17:02 UTC
Quy, are you saying in that case there is more than 1 source or more than 1 rendered document left? I didn't experience
such before, there was always 1 source and 1 rendered doc, as it should. I am going to try out your case.
Comment 13 Quy Nguyen 2008-01-08 17:23:11 UTC
I see 1 RaveRenderedDocument that holds onto multiple RaveSourceDocument objects.
Comment 14 Quy Nguyen 2008-01-08 19:23:56 UTC
Another method to reproduce:

1) Create a vw project
2) Drop a button component
3) Switch to JSP view
4) Make a modification (I changed the button's text attribute value)
5) Switch back to Design view
6) Repeat steps 3-5

This looks like it leaks a RaveSourceDocument object every time steps 3-5 are done.
Comment 15 Peter Zavadsky 2008-01-08 23:51:44 UTC
I checked the later example, and the leak is not caused by RaveRenderedDocument, there is no direct link from it to the
RaveSourceDocument.

The one rather seems to be leaking by FacesBean, or LiveUnit (listeners?) or FacesModel.

Also there were 5 FacesModel instances but designer/jsf had correctly only one JsfForm.

Those last cases seem to belong to insync, passing there.
Comment 16 _ sandipchitale 2008-01-09 16:01:21 UTC
"Also there were 5 FacesModel instances but designer/jsf had correctly only one JsfForm."

Depends on how many pages and request, session and application beans you have. There is one FacesModel for one Page.
There is one JsfForm for one Page. However the other 3 FacesModels are for RequestBean1, sessionBeans1 and
ApplicationBeans1 assuming a normal project. So one additional FacesModel needs explanation. Do you have more than one
page or page fragment?

Quy, can you add some more details of the GCRoot paths.
Comment 17 _ sandipchitale 2008-01-10 00:17:57 UTC
Assigning back to Peter:

RaveRenderedDocument->hashtable->entry->value->hashtable->.....->RaveSourceDocument links.
Comment 18 Peter Zavadsky 2008-01-10 18:19:45 UTC
Yes, it is there, it is needed to add, that the navigator window needs to be closed when proceeding the last case.
Comment 19 Peter Zavadsky 2008-01-11 18:39:05 UTC
Fixed. After this additional patch, the last case seems to be working now.

Checking in visualweb/designer/markup/src/org/netbeans/modules/visualweb/designer/markup/MarkupServiceImpl.java;
/cvs/visualweb/designer/markup/src/org/netbeans/modules/visualweb/designer/markup/MarkupServiceImpl.java,v  <-- 
MarkupServiceImpl.java
new revision: 1.16; previous revision: 1.15
done