Home PC Games Linux Windows Database Network Programming Server Mobile  
           
  Home \ Programming \ Fundamentals of the Java virtual machine memory management principles     - HBase Application Development Review and Summary of Series (Database)

- About Auto Layout and frame (Programming)

- The official release method to upgrade to Ubuntu 15.04 (Linux)

- Logging information through the web GUI (LogAnalyzer) (Server)

- Multi-core CPU, multi-threading and parallel computation (Linux)

- MySQL composite partition (Database)

- Linux Shell Scripting multithreading (Programming)

- JIRA 3.6.2 Upgrade from older version to the new version 6.0.8 (Linux)

- Install the latest development version of Wine on RedHat and Debian-based systems (Linux)

- How to build Memcached Docker container (Server)

- Linux platform Oracle MySQL connection (Database)

- Linux commands to access the cheat sheet (Linux)

- Compile and install Ubuntu Linux 4.0.5 kernel, network and fix vmware kernel module compilation error (Linux)

- Linux Command - ps: a snapshot of the current process (Linux)

- [Android] Eclipse does not update the Android SDK Manager solution [using GoAgent] (Programming)

- command-line tool for send e-mail (Linux)

- RAID disk array Description (Linux)

- How to view the Linux QPS (Linux)

- Web server security policy (Linux)

- Java rewrite equals method (Programming)

 
         
  Fundamentals of the Java virtual machine memory management principles
     
  Add Date : 2018-11-21      
         
         
         
  Jdk: Java programming language, Java virtual machine, Java API class libraries.

Jdk is used to support Java application development environment minimal.

Jre: Java API class libraries in Java SE API subset, Java virtual machine.

Jre supports standard Java environment running.

Program Counter Register: less memory space, can be seen as byte code executed by the current thread line number indicator. Only a Java Virtual Machine Specification no area of ​​provision OutOfMemoryError.

VM Stack: life cycle and the same thread, which describes the Java memory model implemented method: Each method executed simultaneously creates a stack frame for storing local variable table, operand stack, dynamic linking, exporting methods and other information.

Two kinds of exception: StackOverflowError, OutOfMemoryError

Native Method Stack: similar VM Stack, combined direct and Sun HotSpot!

Heap: when the biggest piece of memory, virtual machine start-up, the sole purpose is to store the object instance.

Method Area: class information storage has been loaded in the virtual machine, constants, static variables, even if the compiler compiled code and other data. Java Virtual Machine specification referred to as a logical part of the heap, but an alias called Non-Heap (non-heap), or permanent generations.

Part of the method area: Runtime Constant Pool

Direcrt Memory: not part of the data area of ​​the virtual machine is running, nor is it a virtual machine specification defines the memory area.

 

To create an object - Keyword new

Memory partitioning: a pointer collision (regular heap memory, allocating memory by moving the pointer), the free list (irregular heap memory allocated memory by updating the list of memory).

TLAB (Thread Local Allocation Buffer): thread-local buffer allocated for the created thread will be allocated a separate space, to avoid conflicts of memory allocation, memory allocation enhance efficiency.

Memory layout object: the object header (Header), instance data (Instance Data) and its padding (Padding).

Access positioning objects: Java program by reference the stack (reference) data to manipulate specific objects on the heap.

Information: handle and direct pointer (Sun HotSpot).

OutOfMemoryError exception combat

Tools: Eclipse Memory Analyzer

Memory Leak Memory Leak, Memory Overflow Memory Overflow

 

Determining whether the object of death - heap memory

1, reference counting algorithm: add a reference to the object counter, place whenever there is a reference to it, the counter is incremented; when referring to the failure, the counter is decremented by one; any time counter reaches zero object is no longer being used.

2, reachability analysis algorithm: The "GC Roots" objects as a starting point down the search, when an object has no references to GC Roots chain attached to prove this object is not available.

 

To be or not to be!

1, using the algorithm determine whether the object is to use;

2, if no longer being used, the tag and filter;

Brush Option Is it necessary to perform finalize () method, without the need to perform the following:

l did not cover objects finalize () method;

l finalize () method has been called by the virtual machine;

3, if it is necessary to perform, put the object placed in the F-Queue queue;

4, automatically create a virtual machine from the low-priority Finalizer thread to execute it, that is, from the virtual machine to trigger the execution;

5, GC in the queue object second mark, that is, to re-establish a reference to an object, you can remove the recycling collection;

Note: Any finalize an object () method will only be called once the system!

 

Method zone recovery

Two main parts: the constant waste and useless classes

Control parameters

-Xnoclassgc: Turn off the virtual machine class garbage collection function;

-verbose: class: monitor how many classes are loaded;

-XX: TraceClassLoading, -XX: TraceClassUnLoading: print class is loaded and unloaded process information;

Note: The extensive use of reflection, dynamic proxies, CGLib ByteCode framework and other dynamically generated JSP and OSGI such scenes frequently custom ClassLoader needs to have a virtual machine class uninstall feature to ensure permanent generations will not overflow!

 

Garbage collection algorithm

1, mark - sweep algorithm: prone to memory fragmentation

2, the copy algorithm: two heap is divided into different areas: the new generation (Young) is mainly used to store newborn object old's (Old) main storage applications long life cycle memory objects. Cenozoic (Young) has been divided into three areas: Eden, From Survivor, To Survivor.

By default, the new generation (Young) and the old age of (Old) is the ratio of 1: 2

Default, Edem: from: to = 8: 1: 1

3, Mark - Collation Algorithm

4, generational collection algorithm

HotSpot GC algorithm

Enumerate the root: check individual; (Stop The World, must halt execution of all Java threads execute GC)

In OopMap assistance, HotSpot can quickly and accurately complete the enumeration.

Safety point: only safe point to begin GC pause

Security Zones: extended security points in the security zone can begin GC pause

Garbage collector: garbage collection implementation.

GC logs

GC common parameters

Memory allocation strategy

1, the object priority assignment in Eden: the new generation GC (Minor GC), the old age of GC (Major GC / Full GC)

2, large objects directly into the old year:

3, long-lived objects will enter the old year: for each object defined age (Age) counter. Object born in Eden and after the first Minor GC after still alive, and can be Survicor hold, it will be moved to Survivor space, and the age of the object is set to 1. Each object Survivor "survive" a Minor GC, the age is increased 1, when the age to a certain extent (default 15), was promoted to the old era.

4, Dynamic Object Age determination: The virtual machine is not always claim to a certain extent in order to target age old's promotion, if Survivor space of the same age greater than half the total size of all the objects in space Survivor, age greater than or equal to the age of the object can be direct access to the old era.

5, space allocation guarantees: continuous space old age is greater than the total size of the new generation of the object or the average size of the previous promotion will be Minor GC, otherwise it will be Full GC.

JDK1.5 in, getAllStackTraces () is used to obtain the virtual machine StackTraceElement objects for all threads.

HSDIS: JIT generated code disassembly.

JConsole: Java monitoring and management console based on JMX.

VisualVM: Combine Troubleshooting Tools
     
         
         
         
  More:      
 
- To install and configure the Jetty server and JDK under Ubuntu 14.04.2 (Server)
- The relationship between UNIX and Linux (Linux)
- Download Google Android source code under Ubuntu 4.4 (Linux)
- ASM learning overview (Database)
- Mumble installation source VoIP application on Ubuntu (Linux)
- Spring AOP for logging (Programming)
- Nginx multi-domain certificate HTTPS (Server)
- To install Google Chrome browser under Ubuntu 14.04 LTS (Linux)
- Python-- for anomalies and reflection of objects articles (Programming)
- File easier to compare tools under Linux (Linux)
- Vim highlight lookup operation (Linux)
- Python: Finding meet the conditions specified in the file directory (Programming)
- C ++ stderr / stdout redirected to a file (Programming)
- Ubuntu 14.04 build Gitlab (Linux)
- Struts2 : combobox label use (Programming)
- Linux system security mechanisms to share (Linux)
- Common Linux System Troubleshooting (Linux)
- Axel install plug under CentOS 5/6 acceleration yum downloads (Linux)
- Linux shell in back quotes (`) Application (Linux)
- QEMU code analysis: BIOS loading process (Linux)
     
           
     
  CopyRight 2002-2022 newfreesoft.com, All Rights Reserved.