lz4 / lz4-java

LZ4 compression for Java
Apache License 2.0
1.1k stars 253 forks source link

Delete of native lib doesn't work on Windows #132

Closed broneill closed 4 years ago

broneill commented 5 years ago

This is a duplicate of issue #102, which was closed without actually being fixed. When loading a native library on Windows, the file is locked and cannot be deleted. Attempting to use the "delete on exit" feature doesn't actually work, because the delete attempt occurs before the native library is unloaded.

odaira commented 5 years ago

As far as I searched the Web, there is no reliable way to delete a temporary native library at exit on Windows. https://stackoverflow.com/questions/33226381/cannot-delete-a-temporary-file-when-it-is-used-to-load-a-system-library https://bugs.java.com/bugdatabase/view_bug.do?bug_id=5086661 The only seemingly possible solution would be to call Runtime.runFinalizersOnExit(true);, but this method is deprecated, and I am not sure a library like lz4-java should call this kind of method that might affect the whole program.

However, I found this approach in sqlite-jdbc might help solve the problem. I will investigate it more.

odaira commented 4 years ago

Fixed by 08b3bff3491eafd5238c5adf79113e56f6821e82.