等待状态下的线程对Java进程中的内存的影响 [英] impact of threads in wait state on memory in java process

查看:183
本文介绍了等待状态下的线程对Java进程中的内存的影响的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图确定找出线程处于等待状态对Java进程(更具体地说是内存而不是cpu)的影响的最佳方法.任何可以帮助我弄清其影响的建议(可能通过jvisualvm/jconsole等)都将不胜感激.

I am trying to ascertain the best possible approach of figuring out the impact of threads in wait state on a java process (more specifically memory and not cpu). Any suggestions that would help me figure out their impact (possibly via jvisualvm/jconsole etc) will be greatly appreciated.

更新: 当前处于等待状态的线程数为几百,大约为500.我正在尝试找出检查线程是否可以/将对旧版本的GC产生任何潜在影响的最佳方法.

Update: Current thread count is a few hundred in wait state - approx 500. I am trying to figure out the best way of checking whether it can/will have any potential impact on GC in old generation.

推荐答案

我正在尝试确定找出线程处于等待状态对Java进程(更具体地说是内存而不是cpu)的影响的最佳方法

I am trying to ascertain the best possible approach of figuring out the impact of threads in wait state on a java process (more specifically memory and not cpu)

单个线程的影响将极小.每个线程都会分配一定数量的堆栈空间内存,这些内存是在堆外部分配的.我相信对于64位计算机,通常为512k或1M.可以使用-XX:ThreadStackSize=YYY JVM参数进行自定义,其中YYY是堆栈的大小(以千字节为单位).

The affect of a single thread is going to be extremely minimal. Each thread gets allocated a certain amount of stack-space memory that is allocated outside of the heap. I believe typically this is 512k or 1M for 64-bit machines. This can be customized with the -XX:ThreadStackSize=YYY JVM argument where YYY is the size of the stack in kilobytes.

堆上还具有Thread对象本身,以及JVM保留的各种计费数据.当然,还必须考虑线程拥有的任何对象.

There also is the Thread object itself on the heap as well as the various accounting data kept by the JVM. Certainly any objects that the thread owns also need to be taken into account.

您唯一担心此空间的地方是计划要使用1000个线程或内存限制非常有限.

The only time you worry about this space is if you plan on having 1000s of threads or have very limited memory constraints.

这篇关于等待状态下的线程对Java进程中的内存的影响的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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