Skip to content

Windows Locked Files

Peter Kriens edited this page Apr 7, 2020 · 5 revisions

When running on Windows, sometimes users encounter errors with locked files. The Windows file system, unlike other platforms such as macOS and Linux, results in some situations which cause these errors.

Much work has been made in Bnd/Bndtools to find and resolve all such issues in our codebase. During this work, we have encountered other Eclipse plugins which hold files open which Bnd/Bndtools needs to write such as jar files.

Please use the File Leak Detector to identify which code may be holding open files to assist in resolving any such issues.

Eclipse

The file leak detector can be used inside Eclipse. The downloaded JAR from the site should be added as an agent. This requires changing eclipse.ini to add a new line after -vmargs

-vmargs
-javaagent:file-leak-detector-X.XX-jar-with-dependencies.jar=strong,dumpatshutdown

You can find eclipse.ini in the same directory as eclipse.exe, for example, c;\Users\micro\eclipse\java-oxygen\eclipse.

You should then start Eclipse from the command line and redirect the output to a file. Once you run into the problem, quit. This will dump the open files. Can be quite surprisingly large. You can send them to Peter.Kriens@aQute.biz to be analyzed.

Temporary Solutions

You can set the property -x-overwritestrategy in cnf/build.bnd

classic                         default, as today
delay                           try, if fail, wait 500 ms, and retry 10 times.
gc                              do a garbage collection cycle
disposable-names                use a tmp name and link from real name
    windows-only-disposable-names   same as previous, but only on windows

First try:

-x-overwritestrategy=gc

If you still see it:

-x-overwritestrategy=windows-only-disposable-names   
Clone this wiki locally