协调 jconsole 和 top 的输出

发布于 2024-12-06 06:27:31 字数 238 浏览 4 评论 0原文

我正在尝试研究 Java 中的内存管理。我有一个程序可以创建一个大集合(~500MB)。我运行 java 时没有任何特殊参数。一旦该收集超出范围,我就会使用 System.gc() 调用垃圾收集器。从 jconsole 中,我可以看到使用的堆内存显着减少。对于 top linux 命令的 RES 输出来说,情况并非如此。

我唯一的解释是,一旦 JVM 获得了内存,只要它正在运行,它就不会将其释放给系统。这是正确的吗?

I am trying to look at memory management in Java. I have a program that creates a large collection (~500MB). I run java without any special arguments. Once this collection goes out of scope, I invoke the garbage collector using System.gc(). From jconsole, I can see that the heap memory in use is dramatically reduced. The same cannot be said of the RES output of the top linux command.

My only interpretation is that once the JVM gets hold of memory, it does not release it to the system as long as it is running. Is this correct?

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

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

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文