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 219460 - Netbeans holds jar files unnecessarily
Summary: Netbeans holds jar files unnecessarily
Alias: None
Product: platform
Classification: Unclassified
Component: Filesystems (show other bugs)
Version: 7.4
Hardware: PC Windows 7
: P3 normal with 1 vote (vote)
Assignee: Tomas Hurka
Depends on:
Reported: 2012-10-03 15:36 UTC by Falchion14
Modified: 2013-10-22 19:04 UTC (History)
2 users (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Note You need to log in before you can comment on or make changes to this bug.
Description Falchion14 2012-10-03 15:36:20 UTC
I'm working on a product that spans multiple projects - some projects produce client/server jars and others produce jars shared by the clients and server.  To rebuild the project, we run a top level Ant script outside of Netbeans.  This script, in turn calls "clean" and "build" on the builds scripts inside the /nb directory of each project in the correct order (dependencies matter) to build the jar files.

This would work fine and worked fine before 7.2, except Netbeans and Windows are working together against Ant.  Windows will not let delete a jar file that something else is using (MS's inability to model the behavior of i-node based filesystems is noted, but off topic for this discussion).  Prior to 7.2 this was not a problem, but now Netbeans holds references to some of the jar files even though it is not using them.  This prevents the Ant script from deleting the files and so the clean step fails in the build scripts.

Workaround:  In Netbeans, turn on View=>Toolbars=>Memory.  
1. Click on the memory graph to encourage garbage collection.  
2. After garbage collection, try the ant script again.  
3. Repeat until the build script successfully cleans up all the old jar files.

I run into this problem multiple times a day (every time I need to rebuild from the top level - at least once, often 2-3 times before a successful rebuild).

Is it possible:
1. To have Netbeans not open jar files it isn't using?
2. Make sure Netbeans isn't waiting until finalize() to close the jar files?

Of course, I'm open to other suggestions, solutions and workarounds.


Comment 1 Jaroslav Tulach 2012-10-14 19:51:03 UTC
Recently there was similar report, I guess. It turned out not to be a bug in filesystems.
Comment 2 Falchion14 2012-10-15 14:59:58 UTC
If it is not a bug, it seems like an opportunity to improve that would help some Windows users.  Thanks for looking into this!
Comment 3 Tomas Hurka 2012-10-16 07:01:33 UTC
(In reply to comment #2)
> If it is not a bug, it seems like an opportunity to improve that would help
> some Windows users.  Thanks for looking into this!
I would like to investigate it, but first try the latest NetBeans dev. build. If you can still reproduce it with the latest dev. build, please provide exact steps how to reproduce it. Thanks.
Comment 4 Falchion14 2013-10-18 21:54:15 UTC
(Updated to 7.3 as that is where we currently are using.)

This problem has continued to plague us, but I don't have a good way to reproduce it.  However, I do have a theory that seems to match what I'm seeing and why I can't reproduce it in a small test case.

We have 18 projects and probably more than 2 dozen jars.  When we start an external top level clean and build our Ant script goes through each project and calls "clean" on that project's build.xml.  This alone takes a few seconds.  After a few jar files are deleted, it seems NetBeans wakes up and realizes that some jar files in the dist directories have been removed.  So it starts the background scanning of projects.  Right after that, my Ant script fails because we couldn't delete a dist/jar file.

Now, I wait until the Background Scanning completes (a few more seconds) and then click on the NetBeans' Memory graph to force garbage collection.  Now I can restart the top level build script and it will successfully clean the remaining jars before the next Background Scanning kicks off.

So, it seems to me that my problem is caused by the Background Scanning kicking off during the middle of an external cleaning of the projects.  The Background Scanning is looking at the deleted jars and the remaining jars and in doing so locks the remaining jars so that Ant fails when it tries to delete them.

Does that seem reasonable?  Is there a good workaround, besides what I outlined above (i.e. something less manual)?  Other thoughts?

I won't reopen this unless I don't get a response after sometime, as I think my report is still incomplete, though I'm at a loss how to simply reproduce the problem.  Maybe someone else has a thought on how to test my hypothesis.
Comment 5 Falchion14 2013-10-22 14:56:45 UTC
Reopening in hopes of getting a response.
Comment 6 Falchion14 2013-10-22 15:11:25 UTC
This behavior is reproducible by running clean and build inside NetBeans on a specific project while a Background Scan is in progress.
Comment 7 Falchion14 2013-10-22 15:12:51 UTC
(In reply to Falchion14 from comment #6)
> This behavior is reproducible by running clean and build inside NetBeans on
> a specific project while a Background Scan is in progress.

Or maybe not.  Looks like it was a slightly different problem where something actually was using the jar besides the Background Scan.
Comment 8 Falchion14 2013-10-22 19:04:57 UTC
Problem also exists on NetBeans 7.4.  Marking the issue accordingly.