`
dyllove98
  • 浏览: 1409094 次
  • 性别: Icon_minigender_1
  • 来自: 济南
博客专栏
73a48ce3-d397-3b94-9f5d-49eb2ab017ab
Eclipse Rcp/R...
浏览量:39175
4322ac12-0ba9-3ac3-a3cf-b2f587fdfd3f
项目管理checkList...
浏览量:80245
4fb6ad91-52a6-307a-9e4f-816b4a7ce416
哲理故事与管理之道
浏览量:133369
社区版块
存档分类
最新评论

JVM process Virtual Memory Usage (Resident Set Size) On A Linux 2.6.25 Kernel

阅读更多

Introduction

This article expands on the previous Virtual Memory post by exploring Resident Set Size growth while running a Java program that will consume all available Java Heap memory. Four different JVM implementations are used to compare results of these experiments. These JVMs come from two different vendors(IBM & Sun) and span two different versions of Java (1.5 & 1.6).

This article tries to tie Java Heap utilization, Resident Set Size, and Virtual Memory address space size statistics together.

Experiment Description

The following program was written to slowly consume all Java Heap in a running JVM.

import java.util.HashMap;

class I
{
Integer I [] = null;
public I()
{
I = new Integer[1000000];
}
}

public class Tester
{
HashMap i = null;
public Tester()
{
i = new HashMap(100000);
}
public void run()
{
for(int k = 0; k <1000000; k++)
{
try {
i.put(new Integer(k), new I());
Thread.sleep(1000);
} catch(Exception e) {
e.printStackTrace();
}
}
}
public static void main(String args [])
{
Tester t = new Tester();
t.run();
}
}

This program was used to generate all data presented in this article.

The following JDKs were used in this experiment:

Sun JDK 1.6.0_11
Sun JDK 1.5.0_17
IBM JDK 1.5 (SR9-0)
IBM JDK 1.6 (SR3-0)

A Linux 2.6.25 kernel (Fedora Core 9) running on a VMWare Workstation Virtual Machine (64-bit) was the experiment’s platform.

The Java Heap minimum and maximum were both set to 512MB of memory. In all scenerios, a 64-bit JDK was used. Besides these items, default JVM settings were used.

Java Heap

The Sun JVM uses a multi-generational heap that has three generations. Only two generations are used by application code (the last is used to store Java Class definitions and related data structures). The IBM JVM, by default, is a single-generation heap.

These implementation differences can be seen in the RSS graphs presented below. The Sun JVM fills its young generation, keeps longer-lived objects in Survivor Regions for a time until moving them to the Tenured (Old) Generation of memory. The initial, linear memory growth seen in the Sun graphs is the Young Generation being filled for the first time. Then, Tenured Objects are moved to the Old Generation for the first time; this event corresponds to the first spike in the RSS numbers. Then, the Young Generation is filled again and its contents copied to the Old Generation–the second spike. This pattern continues until the Java Heap is exhausted and the process dies. The details of Sun’s JVM Garbage Collection algorithms will be introduced in a future article.

In the IBM JVM, the single-generation of Java Heap continues to grow (with RSS increasing linearly) until the JVM runs out of memory and the process exits.

The Garbage Collector(s) in each JVM are able to do little to reclaim Java Heap space in these experiments because essentially every object that is allocated is kept(forever or until the JVM runs out of memory, whichever comes first).

Resident Set Size

The following graphs show physical memory (Resident Set Size) used by the java process over its lifetime. The behavior between each vendor’s implementation between 1.5 & 1.6 is relatively constant. The IBM implementation of the Java Heap shows a steady increase of RSS. The Sun implementation initially starts with a steady rise of the RSS data, but then there are a series of large jumps followed by no increase.

The RSS statistics were gathered with the following command:

while [ 1 ]; do ps -eo pid,cmd,rss | grep java | grep -v ps | grep -v grep | awk ‘{print $NF}’; date; sleep 1; done

The steady-state Virtual Memory address space size of each JVM is summarized below. Note, the “steady-state” size is defined as the VIRT statistic that top reports after the java process has been running for ten seconds. In all cases, the VIRT statistic doesn’t increase during the life of the test run (after ten seconds).

IBM 1.5 726MB
IBM 1.6 744MB
Sun 1.5 875MB
Sun 1.6 829MB

IBM Java 1.6

IBM Java 1.5

Sun Java 1.6

Sun Java 1.5

All Data

IBM Java 1.5 With “gencon” Multi-Generational Heap

If the “-Xgcpolicy:gencon” parameter is used to give the IBM JVM Multi-Generational heap, the RSS graph becomes something similar to the following. Obviously, different algorithms are at play here, but you can see where the Older Genereation of the Java Heap is growing in chunks.

Reference

[1] Sun JDK 1.6.0_11
[2] Sun JDK 1.5.0_17
[3] IBM JDK 1.5 (SR9-0)
[4] BM JDK 1.6 (SR3-0)
[5] http://java.sun.com/docs/hotspot/gc5.0/gc_tuning_5.html
[6] http://download.boulder.ibm.com/ibmdl/pub/software/dw/jdk/diagnosis/GCandMemory-042005.pdf

分享到:
评论
1 楼 di1984HIT 2015-03-03  
写的很好,学习了~

相关推荐

    jvm memory

    jvm memory

    jvm-memory-view-0.93.162

    "JVM Memory View"工具,版本号为0.93.162,就是针对这一需求而设计的JVM调试内存查看器,专为Android Studio用户提供了一个直观、高效的内存分析解决方案。 一、JVM内存概述 Java虚拟机内存主要分为以下几个区域...

    Template Jvm Process Dicovery.xml

    Zabbix监控JVM(微服务进程),自动发现模板。 传统的监控方法监控微服务,会造成经常的手动去增加删减web页面配置,服务器内的端口管理也会很混乱。 所以使用discovery自动发现的方式去监控微服务。并将每个微服务...

    Java JVM Instruction Set

    例如,如果我们的Java程序源代码全部位于一个名为`x.java`的文件中,并且我们正在运行Linux操作系统的PC上进行开发工作。 首先,我们需要编译这段代码,使用Java编译器`javac`: ```bash % javac -gx.java ``` 其中...

    java JVM Runtime Data Area and Instruction Set

    java JVM Runtime Data Area and Instruction Set

    processOn, jvm 虚拟机; jvm调优

    processOn, jvm 虚拟机; jvm调优原理;java内存回收机制

    Linux简单调优与JVM参数.docx

    Linux 服务器调优与 JVM 参数调优 本文主要介绍了 Linux 服务器调优和 JVM 参数调优的相关知识点,以便提高服务器性能和 JVM 应用程序的运行效率。 Linux 服务器调优 Linux 服务器调优是指对 Linux 操作系统的...

    MemoryAnalyzer JVM堆内存分析工具

    《深入解析MemoryAnalyzer:JVM堆内存分析利器》 在Java开发中,内存管理是至关重要的环节,良好的内存管理能够优化应用性能,防止内存泄漏,提升系统稳定性。MemoryAnalyzer(MAT)是一款强大的JVM堆内存分析工具...

    MemoryAnalyzer-JVM

    《深入理解MemoryAnalyzer:JVM内存分析利器》 在Java应用程序的开发和优化过程中,内存管理是一项至关重要的任务。MemoryAnalyzer(MAT)是一款强大的JVM内存分析工具,它能够帮助开发者深入洞察应用的内存占用...

    Kernel sockets leak on a multiprocessor computer that is running Windows 7

    此问题是windows的bug,唯一解决问题的方法就是reboot,然后给系统打补丁,The problem was fixed with Microsoft's patch: "Kernel sockets leak on a multiprocessor computer that is running Windows Server ...

    MemoryAnalyzerTool(MAT)linux版

    《MAT在Linux环境下的应用深度解析》 MemoryAnalyzerTool(MAT),全称为Eclipse Memory Analyzer Tool,是一款由Eclipse基金会开发的专业Java内存分析工具。它主要用于诊断和优化Java应用程序的内存消耗,帮助...

    MemoryAnalyzer-1.12.0.20210602-linux.gtk.x86_64.zip

    这个“MemoryAnalyzer-1.12.0.20210602-linux.gtk.x86_64.zip”文件包含了MAT的最新版本,适用于Linux操作系统,并且是为x86_64架构设计的。MAT的持续更新确保了它能适应不断发展的JVM环境,为开发者提供高效、精确...

    JVM调优和Linux常见面试题.zip

    在IT行业中,JVM(Java Virtual Machine)调优和Linux系统操作是两个至关重要的技能,尤其是在处理大型企业级应用时。对于Java开发者来说,理解JVM的工作原理并能进行有效的调优,可以显著提升应用程序的性能和稳定...

    linux 下用java 获取系统信息 cpu mem jvm等

    linux 下用java 获取系统信息 cpu mem jvm等 用java调用系统命令得到,方便实用

    MemoryAnalyzer-1.8.0.20180604-linux.gtk.x86_64.zip

    《深入解析MemoryAnalyzer工具在Linux环境中的应用》 在IT领域,内存管理是优化系统性能的关键环节,尤其是在处理大规模数据和服务高并发的场景下。MemoryAnalyzer(MAT)是一款由Eclipse基金会开发的强大内存分析...

    SWT64位( Cannot load 32-bit SWT libraries on 64-bit JVM)完美解决

    把原来的swt.jar替换成这个就能解决 Cannot load 32-bit SWT libraries on 64-bit JVM问题

    Android代码-终端实现的 JVM 监视器。

    Console based JVM monitoring - when you just want to SSH into a server and see what's going on. jvm-top lets you monitor your JVM server applications from the terminal. Install Requirement: a JDK8 ...

    MemoryAnalyzer-1.10.0.20200225-linux.gtk.x86_64.zip

    《深入解析MemoryAnalyzer工具——基于1.10.0.20200225-linux.gtk.x86_64版本》 MemoryAnalyzer,通常被称为MAT(Memory Analyzer Tool),是一款由Eclipse基金会开发的强大内存分析工具。该工具主要用于诊断Java...

    Introduction to JVM Languages

    Introduction to JVM Languages English | 2017 | ISBN-10: 178712794X | 390 pages | PDF/MOBI/EPUB (conv) | 6.42 Mb Key Features This guide provides in-depth coverage of the Java Virtual Machine and its ...

Global site tag (gtag.js) - Google Analytics