为什么JVM堆不断增长? [英] Why does JVM heap keep growing?

查看:378
本文介绍了为什么JVM堆不断增长?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我编写了一个简单的程序,并使用jconsole.exe来监控其堆大小。

I write a simple program and use jconsole.exe to monitor its heap size.

public class HeapTest {
    public static void main(String[] args) {
        while(true) {
        }
    }
}

结果是

我不明白为什么堆大小会不断增长。我的程序中没有new()任何Object。

I don't understand why the heap size keeps growing. I don't new() any Object in my program.

我的程序中使用的堆是什么?

What is the heap used for in my program?

我没有向jconsole.exe添加任何其他参数;只需双击它,然后根据PID加载java进程。

I don't add any additional arguments to jconsole.exe; just double click on it, then load the java process according to PID.

环境:Windows 7下的Java 1.8.0_25

Environment: Java 1.8.0_25 under windows 7

推荐答案

此处没有内存泄漏。也在OSX中复制它。它将保存由VM正常运行产生的数据,包括GC的数据。 eden上升,一旦GC发生,堆(eden)使用的内存减少,循环再次开始。

There is no memory leak here. Replicated it in OSX as well. It would be the book keeping data generated by the normal functioning of the VM including that for the GC. The eden goes up and once the GC occurs, the memory used by the heap (eden) is reduced and the cycle starts again.

令人困惑的方面是没有程序明确地创建了对象,但有理由说明JVM会这样做,因此伊甸园空间逐渐增加,直到下一个GC。

The confusing aspect is that there are no objects being created explictly by the program but it would make sense to expound that the JVM would be doing so and hence the gradual increase in eden space till the next GC.

这篇关于为什么JVM堆不断增长?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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