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

查看:351
本文介绍了空闲时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应用程序,其中显示了一个显示"hello world"的Swing窗口.当我在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天全站免登陆