java内存泄漏,visualvm显示错误的数据 [英] java memory leak, visualvm showing wrong data

查看:136
本文介绍了java内存泄漏,visualvm显示错误的数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经运行了一个java应用程序,几个小时后就可以运行内存。
我试图用visualvm检测内存泄漏,但它显示错误的数据(不知道怎么会发生这种情况)。

I've a java application running, after few hours it fulfills memory. I've tried to detect memory leak with visualvm but it shows wrong data (have no idea how that can happen).

在屏幕截图中你可以看到任务管理器显示700Mb的内存使用率和visualvm显示225 ...

In the screenshot you can see task manager showing memory usage of 700Mb and visualvm showing 225...

有谁知道这里发生了什么?

Does anyone know whats going on here?

问候

推荐答案

请注意,您的操作系统只知道java保留的内存总量(并且java不会返回该数量)记忆容易AFAIK)。但是java可能没有在给定时刻使用所有内存,因此您可以看到这两个数字之间的差异。

Beware that your OS is only aware of the total amount of memory java has reserved over the time (and java will not return that amount of memory easily AFAIK). However java may not be using all that memory at a given moment, so you can see differences between those two numbers.

例如,如果您启动这样的程序

For example, if you launch your program like this

java -Xmx512m -Xms256m ...

然后你的JVM一启动就会占用256 MB(操作系统会或多或少地告诉你)。但是,如果你打开你的内存窥视工具(无论是visualvm,jconsole等),它可能表明你使用的不到那个(只是你不需要使用整个保留堆)。

Then your JVM will take 256 MB as soon as it starts (and the OS will tell you so, more or less). However, if you open your memory peek tool (be it visualvm, jconsole, etc.), it may show that you are using less than that (it is just you have not needed to use the whole of your reserved heap).

这篇关于java内存泄漏,visualvm显示错误的数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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