首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > 编程 >

从一个例证看JVM启动过程(1)

2012-09-16 
从一个例子看JVM启动过程(1)开题从一个例子说起:public class NativeMemoryGC{@SuppressWarnings(restric

从一个例子看JVM启动过程(1)
开题从一个例子说起:

public class NativeMemoryGC{    @SuppressWarnings("restriction")    public static void main(String[] args) throws SecurityException, NoSuchFieldException, ClassNotFoundException, IllegalArgumentException, IllegalAccessException, InterruptedException    {     System.out.println("maxMemoryValue:"+sun.misc.VM.maxDirectMemory());                Class c = Class.forName("java.nio.Bits");        Field maxMemory = c.getDeclaredField("maxMemory");        maxMemory.setAccessible(true);        synchronized (c) {            Long maxMemoryValue = (Long)maxMemory.get(null);            System.out.println("maxMemoryValue:"+maxMemoryValue);        }     }}


Bits.java
   
private static volatile long maxMemory = VM.maxDirectMemory();

执行结果:
maxMemoryValue:259522560
maxMemoryValue:67108864

从源代码来看2者皆是调用的VM类的静态方法maxDirectMemory(),为什么2者会有不一样的结果呢??
------内网字数限制,需要分篇解析-----

热点排行