欢迎访问悦橙教程(wld5.com),关注java教程。悦橙教程  java问答|  每日更新
页面导航 : > > 文章正文

Java,

来源: javaer 分享于  点击 2172 次 点评:20

Java,


分享一个大牛的人工智能教程。零基础!通俗易懂!风趣幽默!希望你也加入到人工智能的队伍中来!请点击http://www.captainbed.net 

In Java, allocation and de-allocation of memory space for objects are done by the garbage collection process in an automated way by the JVM. Unlike C language the developers need not write code for garbage collection in Java. This is one among the many features that made Java popular and helps programmers write better Java applications.

This is a four part tutorial series to know about the basics of garbage collection in Java,

This tutorial is the first part in the series. It will explain the basic terminologies like JDK, JVM, JRE, HotSpot VM then understand the JVM architecture and Java heap memory structure. It is important to understand these basic things before going into the Garbage collection tutorial.

Key Java Terminologies

  • Java API – is a collection of packaged libraries that helps developers to create Java applications.
  • Java Development Kit (JDK) – is a set of tools that enables a developer to create Java applications. JDK includes tools to compile, run, package, distribute and monitor Java applications.
  • Java Virtual Machine (JVM) – JVM is an abstract computing machine. Java programs are written against the JVM specification. JVM is specific for OS platform and they translate the Java instructions to the underlying platform specific instructions and execute them. JVM enables the Java programs to be platform independent.
  • Java Runtime Environment (JRE) – JRE comprises the JVM implementation and the Java API.

Java HotSpot Virtual Machine

Each JVM implementation may be different in the way the garbage collection principles are implemented. Prior to SUN takeover Oracle had JRockit JVM and after takeover it got the HotSpot JVM. Presently Oracle maintains both the JVM implementations and it has declared that over a period these two JVM implementations will be converged to one.

HotSpot JVM is available as a core component as part of the standard Oracle SE platform. In this garbage collection tutorial, we will see the garbage collection principles based on the HotSpot Virtual Machine.

JVM Architecture

Following diagram summarizes the key components in a JVM. In the JVM architecture, two main components that are related to garbage collection are heap memory and garbage collector. Heap memory is the runtime data area where the instances will be store and the garbage collector will operate on. Now we know how these things fit in the larger scheme.

Java Heap Memory

It is essential to understand the role of heap memory in JVM memory model. At runtime the Java instances are stored in the heap memory area. When an object is not referenced anymore it becomes eligible for eviction from heap memory. During garbage collection process, those objects are evicted from heap memory and the space is reclaimed. Heap memory has three major areas,

  • Old Generation (instances promoted from S1 to tenured)
  • Permanent Generation (contains meta information like class, method detail)
  • Update: Permanent Generation (Permgen) space is removed from Java SE 8 features.

    相关文章

      暂无相关文章
    相关栏目:

    用户点评