空闲时的JVM锯齿模式?JVM 在此期间做了什么? [英] JVM sawtooth pattern when idle? what does the JVM do in the meantime?

查看:19
本文介绍了空闲时的JVM锯齿模式?JVM 在此期间做了什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道.我有一个带有 servlet 的简单 Java Web 项目.当没有用户使用它时(我在 GlassFish 上本地托管它),我仍然在进程的内存使用中看到锯齿模式.我似乎无法理解 JVM 在做什么?我了解JVM使用的内存的正常流动.堆中充满了应用程序正在创建的对象.在某个点,堆到达垃圾收集器进入的点,它将删除所有不再使用的缓存"对象,以便可以创建新对象并可以填充堆大小.

I was wondering. I have a simple Java web project with a servlet. When no users are using it (I host it local on GlassFish) I still see a sawtooth pattern in the memory usage of the process. I can't seem to understand what the JVM is doing? I understand the normal flow of the memory used by JVM. The heap is getting filled with objects the application is creating. At a certain point the heap reaches a point where the garbage collector comes in, which will remove all the 'cached' objects which no longer are used, so that new objects can be created and can be filled in the heap size.

我想知道的是,JVM 在空闲时一直在做什么?

What I wonder is, what is the JVM doing all the time when it's idle?

就像我在评论中所说的那样.我在 Eclipse 中创建了一个非常简单的 Java 应用程序,它显示了一个 Swing 窗口,上面写着hello world".当我在 Java VisualVM 中观察 JVM 的内存使用情况时,我看到了相同的锯齿模式.

Like I said in the comments. I created a very simple Java application in Eclipse which showed a Swing window saying 'hello world'. When I watch the memory usage of the JVM in Java VisualVM, I see the same sawtooth pattern.

推荐答案

原来VisualVM是罪魁祸首.这是因为 VisualVM 不断地询问 JVM 它的统计数据是什么,因此 JVM 创建对象以将信息提供给 VisualVM.

It turns out that VisualVM is the guilty one. This is because VisualVM constantly asks the JVM what it's statistics are, so the JVM creates objects to give the information to VisualVM.

感谢彼得·劳瑞

这篇关于空闲时的JVM锯齿模式?JVM 在此期间做了什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆