执行jmap时JVM是否停止了? [英] Is a JVM stopped while executing jmap?

查看:724
本文介绍了执行jmap时JVM是否停止了?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当jmap进行内存转储时,我的Java应用程序是否可以继续运行?

Does my java application continue running while jmap is taking its memory dump?

推荐答案

您的应用程序已停止.获得准确的堆转储的唯一实际方法是在创建转储时停止所有应用程序活动.

Your application is stopped. The only practical way to get an accurate heap dump would be to stop all application activity while the dump is being created.

这是简短"暂停还是长时间"暂停取决于所转储的数量.如果使用"-dump",则将转储整个堆,包括不可达的对象.如果使用"-dump:live",则将仅转储可访问的对象……但这也(至少)需要标记堆以找出可访问的对象.

Whether this is a "brief" pause or a "long" pause depends on how much is dumped. If you use "-dump" then you will dump the entire heap, including unreachable objects. If you use "-dump:live" you will only dump reachable objects ... but that also entails (at least) marking the heap to figure out which objects are reachable.

但是,如果要转储1 GB的堆,则希望暂停时间以分钟而不是秒为单位.

But if you are dumping a gigabyte sized heap, expect the pause time to be measured in minutes rather than seconds.

关于可以避免使用fork来停止JVM的建议,事实证明分叉多线程进程可能会引起问题:

Re the suggestion that you could avoid stopping the JVM by using fork, it turns out that forking a multi-threaded process can be problematic:

  • fork in multi-threaded program
  • Multithreaded fork
  • http://www.linuxprogrammingblog.com/threads-and-fork-think-twice-before-using-them

然后是资源使用问题.

这篇关于执行jmap时JVM是否停止了?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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