内存池“Perm Generation” (non-heap): 保存虚拟机自己的静态(refective)数据,例如类(class)和方法(method)对象。Java虚拟机共享这些类数据。这个区域被分割为只读的和只写的
内存池“Code Cache”(non-heap):HotSpot Java虚拟机包括一个用于编译和保存本地代码(native code)的内存,叫做“代码缓存区”(code cache) 详细信息区域给出一些当前线程的信息:
已使用:当前的内存使用量。使用的内存包括所有对象(能被获取和不能被获取的)所占用的内存。
分配:Java虚拟机保证能够获取到的内存量。分配内存(committed memory)的量可能随时间改变。Java虚拟机可能释放部分这里的内存给系统,相应的分配的内存这时可能少于初始化时分配的给它的量。分配量总数大于或等于已使用的内存量。
最大值:内存管理系统可以使用的最大内存量。这个值可以被改变或者不做设定。如果JVM试图增加使用的内存到大于分配量(committed memory)的情况,内存分配可能失败,即便想使用的内存量小于或者等于最大值(如:系统虚拟内存比较低时)
GC 时间 :垃圾回收使用的总时间和调用垃圾回收的次数。它可能有好几行,每行代表JVM使用的垃圾回收算法。
Usage Threshold The usage threshold of a memory pool. This field will only beshown if the memory pool supports usage threshold.
右下角的棒状图表显示了被JVM的内存池消耗的内存。如果内存使用超过 usage threshold,则棒会变红。usagethreshold是用于支持内存检查的Memory Pool MBean的一个属性。MemoryPoolMXBean定义了一系列方法用于检查内存。 public interface MemoryPoolMXBean { // Usage threshold
public long getUsageThreshold();
public void setUsageThreshold(long threshold); public boolean isUsageThresholdExceeded(); public boolean isUsageThresholdSupported(); // Collection usage threshold
public long getCollectionUsageThreshold();
public void setCollectionUsageThreshold(long threshold);
public boolean isCollectionUsageThresholdSupported(); public boolean isCollectionUsageThresholdExceeded(); }
每种内存池可能有两种内存初始话支持: usage threshold和collection usage threshold特殊的内存池可能两种都不支持。 Usage Threshold
usage threshold是内存池中一个可管理的属性。它使用低负荷的内存监控。设置usage threshold为正值则usage threshold检查内存池。设置usage threshold为零,则关闭检
查。默认值由JVM设置。JVM一般让usage threshold在最合适的时候检查内存,典型的在GC的过程中和某些分配内存的时候。如果JVM发现当前的内存使用超过了usage threshold,它将会把UsageThresholdExceeded属性设置为true
有些内存池可能不支持usage threshold。你可以使用UsageThresholdSupported属性来判断一个内存池是否支持usage threshold。例 如,一个比较完善(generational garbage collector)的垃圾回收器(如HotSpot的虚拟机),most of the objects are allocated in the young generation,从eden内存池中产生。eden pool被设计成可以被装满;再eden pool中执行垃圾回收将会释放他 Collection Usage Threshold
Collection usage threshold是可进行垃圾回收的内存池的一个可配置属性。JVM堆一个内
存池进行 垃圾回收以后,此内存池中的一些内存仍然被那些没有被回收的对象占用。collection usage threshold仅允许你在垃圾回收后对内存进行检查。如果JVM发现可用内存超出collection usage threshold,它将会设置CollectionUsageThresholdExceeded属性为true。
你可以使用CollectionUsageThresholdSupported属性来控制内存池释放支持 collection usage threshold.
usage threshold 和collection usage threshold是MBean标签中的一组。例如,在左边的树形结构中选择TenuredGen,设置tenured generation memory pool的usage threshold为6m。如下图所示
图7 设置 Usage Threshold
当 TenuredGen memory pool的内存使用超过6MBytes时,代表 TenuredGen memory pool的柱状图将会呈现红色来代表使用的内存超过了usage threshold。代表堆内存的柱状图也将变为红色。你可以选择柱状图或者在图表中指定内存池来查看某个指定内存池的信息。如果把鼠标房子柱状图上,将会显示出内存池的名字
图8 Low Memory
8.5.3 开启和关闭虚拟机的详细跟踪
如上所述,内存系统的MBean定义了一个叫做Verbose布尔变量,让你能动态的打开或关闭详细的GC跟踪。详细的GC跟踪,将会在JVM启动时显示。默认的HotSpot的GC详细输出为stdout.
图 9: 设置 Verbose GC
8.5.4 死锁检查
线程标签页提供关于应用的线程运行信息
百度搜索“77cn”或“免费范文网”即可找到本站免费阅读全部范文。收藏本站方便下次阅读,免费范文网,提供经典小说综合文库java_实用工具笔记(5)在线全文阅读。
相关推荐: