问题
I am using springboot 2.1.4 with EmbeddedTomcat. When i run my server, /tmp/jar_cache###.tmp is created. How can i handle with jar_cache###.tmp?
I am using CENTOS 7 and java version "1.8.0_162".
If i change tmpdir to other directory, not /tmp, then how can i handle with a lot of jar_cache### that is created by default?
Using /tmp directory, What if jar_cache was cleared that was using in my application?
java 46030 www DEL REG 253,2 2830 /tmp/jar_cache7122103988160656171.tmp
java 46030 www DEL REG 253,2 2842 /tmp/jar_cache8134973409906757503.tmp
java 46030 www 25r REG 253,2 414240 2830 /tmp/jar_cache7122103988160656171.tmp (deleted)
java 46030 www 27r REG 253,2 800016 2842 /tmp/jar_cache8134973409906757503.tmp (deleted)
回答1:
There is apparently a bug in some versions of SpringBoot that leads to jar_cache
files (in DEL state) accumulating:
- https://github.com/spring-projects/spring-boot/issues/9866 dup of #9240
- https://github.com/spring-projects/spring-boot/issues/9240 resolved
According to the issue tracker links, this was fixed in SpringBoot 2.0.0.
Now I see from your question that you are using 2.1.4, so it probably isn't the specific issue above that is causing your problem. However, there are likely to be clues in the first link that may help you to work out what your problem is caused by.
To answer your questions:
- Yes these are created by default, but they should be cleaned up when you application restarts.
- I expect changing
TMPDIR
will affect where the files are created. Try it and see! - Deleting the files from the directory won't free any file space if the application still has the files open.
It might also be possible to get the files to go away by calling System.gc()
. Yes, it is generally a bad idea to call System.gc()
for performance reasons. But this could be a workaround if the cache files are really a problem.
来源:https://stackoverflow.com/questions/55841072/how-can-i-handle-with-tmp-jar-cache-tmp