Java 临时文件 (jar_cache####.tmp) 使用资源(文件描述符和内存)多长时间?

发布于 2024-09-25 18:08:47 字数 750 浏览 3 评论 0原文

我正在 Linux 系统上运行 Java 应用程序。我注意到该应用程序似乎消耗了大量文件句柄(几天后我收到“打开文件过多”)。

因此,当我使用“lsof”命令转储与 Java 应用程序关联的所有文件,我得到这样的信息:

java  2690  root  239u  REG  3,2  428057  94300 /tmp/jar_cache5782499018536796385.tmp (deleted)
java  2690  root  240u  REG  3,2  58955   94360 /tmp/jar_cache3818842806647031366.tmp (deleted)
java  2690  root  241u  REG  3,2  28673   94301 /tmp/jar_cache8793213887943479521.tmp (deleted)
java  2690  root  242u  REG  3,2  67115   94302 /tmp/jar_cache3648070144390426051.tmp (deleted)

我在这里只显示了 4 个文件,但实际上有 87 个,而且

根据我在网上阅读的内容,这个数字会随着时间的推移而增长,Java 使用这些临时文件。 正如上面

的输出所示,它们被删除,并且我确认它们在文件系统上物理上不存在,

但我担心的是它不会释放文件描述符或任何文件。相关内存的...有谁知道这些“/tmp/jar_cache####.tmp”文件或有这些文件的经验吗?

I"m running a Java application on a Linux system. I noticed that the application seemed to consume a lot of file handles (I get "Too many open files" after a few days).

So when I use the 'lsof' command to dump all the files associated with the Java application, I get something like this:

java  2690  root  239u  REG  3,2  428057  94300 /tmp/jar_cache5782499018536796385.tmp (deleted)
java  2690  root  240u  REG  3,2  58955   94360 /tmp/jar_cache3818842806647031366.tmp (deleted)
java  2690  root  241u  REG  3,2  28673   94301 /tmp/jar_cache8793213887943479521.tmp (deleted)
java  2690  root  242u  REG  3,2  67115   94302 /tmp/jar_cache3648070144390426051.tmp (deleted)

I'm only showing 4 here, but there are actually 87 of them and the number grows in time.

From what I've read online, Java uses these temporary files internally or something and they are normal.

As the output above says, they are deleted, and I confirm that they do not exist physically on the file system.

But what I'm afraid of is that it's not releasing the file descriptors or any of the associated memory... does anyone know anything about these '/tmp/jar_cache####.tmp' files or have experience with these?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

眼睛会笑 2024-10-02 18:08:56

/tmp/jar_cache 文件是通过 URLClassloader 加载 jar 时生成的。我怀疑应用程序的某些组件正在重新加载,这会导致旧的 jar_cache 文件被删除并创建新的文件。事实上,文件句柄没有被释放似乎是一个 JVM 问题——我在相同的 JDK 版本中也看到过这种行为。

关于这个 JVM bug 有这样的评论:
https://bugs.java.com/bugdatabase/view_bug?bug_id=4166799

尽管该问题不久前已关闭。

The /tmp/jar_cache files are produced when loading a jar via a URLClassloader. I suspect there are components of the application that are being reloaded and this results in old jar_cache files being deleted and new ones created. The fact that file handles are not released seems like a JVM issue though - I've seen this behavior as well with the same JDK version.

There are comments along these lines on this JVM bug:
https://bugs.java.com/bugdatabase/view_bug?bug_id=4166799

although the issue was closed a while ago.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文