From: Adam R. <ad...@ex...> - 2012-01-30 22:52:58
|
It was bought to my attention that temporary files were not being cleaned up on the Windows platform. Basically if you use a memory mapped file in eXist-db, e.g. through calling an operation on a stream, almost anything that returns base64binary - e.g. request:get-data(), then temporary files are created in $EXIST_HOME/tools/jetty/tmp Simply opening eXide, and opening an XQuery from the database and hitting refresh multiple times will cause the issue. On Unix/Linux/Mac these files are deleted automatically by the function finalize() calling tempFile.delete() in the class org.exist.util.io.MemoryMappedFileFilterInputStreamCache. This is the correct behaviour! However... On Windows platforms, calling tempFile.delete() does not delete the file and returns false, even attempting tricks with System.gc() and a thread pause, which has been known to work around the Windows JDK platform bugs in File.renameTo() does not work here. I am at a loss as how to fix this on Windows platforms. I have also checked JDK 7 on Windows, and the same problems exist there. If anyone knows of a mechanism please let me know. I cannot find a solution via Google so far. At the moment, I can only imagine a workaround to re-use files that cannot be deleted. This may be sufficient but far from perfect, and I must say I loathe the fact that the Windows JDK really sucks here. The code I used for debugging this behaviour, simply replace that finalize method with - @Override protected void finalize() throws Throwable { super.finalize(); if(tempFile != null) { boolean deletedFile = tempFile.delete(); System.err.println("deleted file (1st): " + deletedFile); if(!deletedFile) { System.gc(); Thread.sleep(50); deletedFile = tempFile.delete(); System.err.println("deleted file (2nd): " + deletedFile); } } } -- Adam Retter eXist Developer { United Kingdom } ad...@ex... irc://irc.freenode.net/existdb |