DeleteOnExit can accumulate memory
File.deleteOnExit stores paths until JVM shutdown, so repeated use in a long-running process can grow memory and delay cleanup. Delete temporary files explicitly when possible.
deleteOnExitdoes not run if the JVM is killed with SIGKILL or halted withRuntime.halt. If you have hit a variant of this, share it below.File.deleteOnExit keeps every registered path in memory until the JVM exits. In a long-running process that repeats this, memory grows and cleanup waits too long; delete files explicitly instead.
Registrations from deleteOnExit accumulate for the whole JVM lifetime, which matters in servers. Calling delete on each temp file as soon as it is no longer needed avoids that growth.
"DeleteOnExit can accumulate memory" is a useful thing to know about with java / files. Thanks for sharing it.
Good to see "DeleteOnExit can accumulate memory" written down. Handy reference for anyone working with java / files.
Short scripts are unaffected by deleteOnExit, but a service that creates files continuously builds up a list of paths. Explicit deletion keeps both memory and disk usage bounded.
Appreciate the write-up on "DeleteOnExit can accumulate memory". Useful for anyone using java / files.
"DeleteOnExit can accumulate memory" is a useful thing to know about with java / files. Thanks for sharing it.
Specific and to the point: "DeleteOnExit can accumulate memory". Worth a look if you touch java / files.