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 231428 - memory leak in org.netbeans.modules.web.jsf.api.metamodel.ModelUnit
Summary: memory leak in org.netbeans.modules.web.jsf.api.metamodel.ModelUnit
Status: RESOLVED FIXED
Alias: None
Product: javaee
Classification: Unclassified
Component: JSF (show other bugs)
Version: 7.4
Hardware: All All
: P2 normal (vote)
Assignee: Martin Fousek
URL:
Keywords: PERFORMANCE
Depends on:
Blocks:
 
Reported: 2013-06-18 11:15 UTC by Petr Cyhelsky
Modified: 2013-07-26 02:49 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 Petr Cyhelsky 2013-06-18 11:15:54 UTC
after all projects are closed one instance of org.netbeans.modules.java.j2seproject.J2SEProject is still held in memory. See the offending instance in heapdump at: https://netbeans.org/projects/performance/downloads/download/heapdumps/Heapdump_web_jsf.7z
Comment 1 Martin Fousek 2013-06-20 12:26:24 UTC
Should be fixed in web-main #6b7fa0ef35fd.
Comment 2 Quality Engineering 2013-06-21 02:29:49 UTC
Integrated into 'main-golden', will be available in build *201306202301* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main-golden/rev/6b7fa0ef35fd
User: Martin Fousek <marfous@netbeans.org>
Log: #231428 - memory leak in org.netbeans.modules.web.jsf.api.metamodel.ModelUnit
Comment 3 Petr Cyhelsky 2013-07-09 15:03:54 UTC
The project is still being held via its source path
can you please consider also weakreferencing the field:

private final ClassPath sourcePath;

I've tried running the IDEValidation with the weakreferenced sourcePath and all went smoothly...
Comment 4 Martin Fousek 2013-07-10 05:05:18 UTC
(In reply to comment #3)
> The project is still being held via its source path
> can you please consider also weakreferencing the field:
> 
> private final ClassPath sourcePath;

It means that sourcePath indirectly holds also the reference to the project? Please could you attach new heapdump or let me know how can I reproduce your tests? Thanks a lot.

> I've tried running the IDEValidation with the weakreferenced sourcePath and all
> went smoothly...

Yeah, it's possible. I would like just to take a look on the new heapdump, thanks.
Comment 5 Martin Fousek 2013-07-11 09:15:32 UTC
(In reply to comment #3)
> The project is still being held via its source path
> can you please consider also weakreferencing the field:
> 
> private final ClassPath sourcePath;

The original problem was resolved, the another issue looks to be in holding of its classpath + filechange listener.

> I've tried running the IDEValidation with the weakreferenced sourcePath and all
> went smoothly...

I'm afraid that I'm not able to validate my change since I don't have steps how to get this heap dump. Please could you attach them once the issue would remains.

It should be fixed in web-main #0ed75a98c0ca. Please give it try whether it's ok or not. Thanks a lot!
Comment 6 Quality Engineering 2013-07-12 02:33:07 UTC
Integrated into 'main-silver', will be available in build *201307112300* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)

Changeset: http://hg.netbeans.org/main-silver/rev/0ed75a98c0ca
User: Martin Fousek <marfous@netbeans.org>
Log: #231428 - memory leak in org.netbeans.modules.web.jsf.api.metamodel.ModelUnit - listeners
Comment 7 Petr Cyhelsky 2013-07-22 14:38:03 UTC
I'm sorry to open this again, but there is still one reference left. Please see heap dump at https://netbeans.org/projects/performance/downloads/download/Heapdump_jsf_model.7z
The problem is that there is static WeakHashMap MODELS in org.netbeans.modules.web.jsf.api.metamodel.JsfModelFactory. This map has the projects as it's key, which is okay iff the value does not strongly reference it, which it does, as can be seen in the dump.
It may be worth considering if it is even needed to have the static map there or if it is possible/better to use project lookup to get the model.
Comment 8 Quality Engineering 2013-07-25 02:29:43 UTC
Integrated into 'main-silver', will be available in build *201307242300* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)

Changeset: http://hg.netbeans.org/main-silver/rev/7f65672757db
User: Tomas Hurka <thurka@netbeans.org>
Log: bugfix #231428, implement profilingPoint() in subclasses; implementation in LockGraphBuilder does nothing
Comment 9 Martin Fousek 2013-07-25 06:52:21 UTC
(In reply to comment #7)
> I'm sorry to open this again, but there is still one reference left.

No problem. Thanks for reopening if it's still valid - that the previous references hid another one. I haven't steps how to reproduce it so I'm not able to test it by myself.

> The problem is that there is static WeakHashMap MODELS in
> org.netbeans.modules.web.jsf.api.metamodel.JsfModelFactory. This map has the
> projects as it's key, which is okay iff the value does not strongly reference
> it, which it does, as can be seen in the dump.
> It may be worth considering if it is even needed to have the static map there
> or if it is possible/better to use project lookup to get the model.

Although I would be probably able to remove also this reference and keep the map, I rewrote the model caching into project lookup as was recommended by you and TomasH. BTW, JsfModelProviderImpl creates the model lazy.

I believe it will solve this issue for ever, feel free to reopen or comment if would be anything wrong, thanks a lot!

web-main #5c2f6be50dca
Comment 10 Quality Engineering 2013-07-26 02:49:58 UTC
Integrated into 'main-silver', will be available in build *201307252300* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)

Changeset: http://hg.netbeans.org/main-silver/rev/5c2f6be50dca
User: Martin Fousek <marfous@netbeans.org>
Log: #231428 - memory leak in org.netbeans.modules.web.jsf.api.metamodel.ModelUnit