【JVM内存模型】实例分析

In a nutshell primitive, object and class data are stored in 3 different memory areas: heap space, method area and native area. The heap space holds object data, the method area holds class code, and the native area holds references to the code and object data.

简单地说,对象和类的数据存储在3个不同的内存区域:堆区、方法区和本地区。 堆区持有对象数据,方法区持有类的代码,本地区持有代码和对象数据的引用。


The method area is also known as the permanent generation space (PermGen). All class data are loaded into this memory space. This includes the field and method data and the code for the methods and constructors.




All objects being instantiated during runtime are stored in the heap space. The heap space again is divided into several parts: eden, survivor, and old generation Space.

Method executions are within a thread. Local variables of primitive types and references are stored here. The references for example points to Objects like String stored in the Heap space

下面是一个实例:

public class HelloWorld {
	
	private static Logger LOGGER = Logger.getLogger(HelloWorld.class.getName());
	
	public void sayHello(String message){
		
		SimpleDateFormat formatter = new SimpleDateFormat("dd.MM.YYYY");
		String today = formatter.format(new Date());
		
		LOGGER.info(today + ": " + message);
	}
	
}

数据存储形式:




参考资料:

    http://www.pointsoftware.ch/en/under-the-hood-runtime-data-areas-javas-memory-model/


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值