码迷,mamicode.com
首页 > 其他好文 > 详细

JVM(essential)

时间:2017-09-29 21:04:58      阅读:111      评论:0      收藏:0      [点我收藏+]

标签:观察   engine   methods   nbsp   ons   lan   jdk   pil   new   

  • JVM JRE JDK
  1. JVMabstract machine:platform dependent 
  2. JVMfunction:1 load codes;2verify codes(strictly typed)--compile error; 3excute the codes;4provide runtime environment
  3. runtime environment:actual implementation of JVM, JVM is in jre(physically present), jre contains libraries and other files JVM uses.
  4. JDK contains JRE+development tools(like javac),also physically present

class loader + runtime data areas + excution engine 

  • class loader{load + link + initialize}

 

  • load{ bootstrap class loader<- extension class loader<-application class loader,查找.class文件顺序 }
  1. 通常class file not found
  2. load from .class or .jar file which contains .class file
  3. loader  implement不同则接收不同data source
  4. bootstrap class loader: load rt.jar
  5. extension class loader:load form jre/lib/ext folder
  6. application class loader:load from CLASSPATH -cp
  7. CLASSPATH and settings
    1. .class重名 ,-cp 选择在CLASSPATH中第一个出现的.class文件
    2. 而-Xmx设置则选择后者 java -Xmx128m -Xmx256m Hello.class 
    3. jinfo -flag MaxHeapSize pid 查看
  • link{verify + prepare +resolve}
  1. verify byte codes
  2. memory allocation for class vars to default value 
  3. resolve: all symbolic references inside the current class(references to其他classes 或 to values constants pool)
  4. resolve通常产生class def not found,即class文件中所有对其他class 或methods的引用not found
  • initialize
  1. static block
  2. set values for static vars(vars to initalized value)

 

  • runtime data areas

Method + Heap + Java Stacks + PC registers +Native method Stacks

  • method area
  1. stored metadata corresponding to class(reflectionAPI所为即访问这里的metadata数据)
  2. 比如static var ,constants pool等class level的data  分配给JVM的内存,-XX:MaxPermSize 默认值64MB
  3. 内存不够 java.lang.OutOfMemoryError:PermGen space...
  4. !!java8 中为meta space并且没有限制 将PermGen space移到了native os的一个分开的内存
  • heap
  1. object data, 每一次new 或arrys等
  2. -Xms -Xmx 最小最大的内存 分配
  • programcounter register
  1. 对每个thread有一个program counter
  2. counter则是指向下一instruction的指针
  • stack
    1. 每个thread 有一个stack
    2. 将thread的不同methods push到stack中
    3. 如m1 call m2那么将在m1基础上push m2到stack中,return则将m2 pop out
    4. 数据如 parameters , parameter array,local vars, return values, operant stack(暂存区进行操作)
    5. java.lang.StackOverflowError    -Xss
  • native method stack
  1. 如 call .dll /.so文件在本地 lib

每个JVM只有一个method area和heap,但thread级是stack,如果彼此不交互则threadsafe

 

  • excution engine

{interpreter + JIT compiler+hostspot profiler+garbage collector}

  •  interpreter
  1. interpret the current bytecode instruction
  • Just-In-Time compiler &hotsot profiler
  1. 对于重复的指令则不再重复用interpreter而是保存起来
  2. hotsot 根据interpreter行为特点的观察,发现不断地重复执行相同指令,让JIT compiler保存
  • GC
  1. clean up unused calsses objects and memory areas

 

 

  • JNI java native interface  (medium for java method calls for native methods . provide info about native library to JVM

JVM(essential)

标签:观察   engine   methods   nbsp   ons   lan   jdk   pil   new   

原文地址:http://www.cnblogs.com/yumanman/p/7612454.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!