NativeLibraryLoader.java creates a temporary directory NATIVES_DIR, and extracts the Luau native library files there. However, there is no shutdown hook or deleteOnExit() call for any of these files, so they remain after the JVM terminates. This either pollutes the filesystem, or leaks memory (if the temporary files are in-memory, as is usually the case with /tmp on linux).
Solving it should be as simple as:
--- src/main/java/net/hollowcube/luau/util/NativeLibraryLoader.java
+++ src/main/java/net/hollowcube/luau/util/NativeLibraryLoader.java
@@ -20,8 +20,9 @@
static {
try {
NATIVES_DIR = Files.createTempDirectory("luau-natives");
+ NATIVES_DIR.deleteOnExit();
} catch (IOException e) {
throw new RuntimeException(
"Failed to create temporary directory for native libraries",
e
@@ -44,8 +45,9 @@
System.mapLibraryName(name)
);
try (InputStream in = innerPath.openStream()) {
Files.copy(in, targetPath);
+ targetPath.toFile().deleteOnExit();
System.load(targetPath.toString());
return true;
} catch (IOException e) {
return false;
NativeLibraryLoader.javacreates a temporary directoryNATIVES_DIR, and extracts the Luau native library files there. However, there is no shutdown hook ordeleteOnExit()call for any of these files, so they remain after the JVM terminates. This either pollutes the filesystem, or leaks memory (if the temporary files are in-memory, as is usually the case with/tmpon linux).Solving it should be as simple as: