Home PC Games Linux Windows Database Network Programming Server Mobile  
           
  Home \ Programming \ Fundamentals of the Java virtual machine memory management principles     - On the PC goes heavy security watch your startup items (Linux)

- MySQL + Corosync + Pacemaker + DRBD build highly available MySQL (Server)

- Python method to traverse folders and file read and write (Programming)

- GoldenGate update is missing (Database)

- Configure the Linux kernel and use iptables to do port mapping (Linux)

- The several technical presentation Raid under Linux (Linux)

- Oracle11g CRS-0184 Problem Solving (Database)

- Text analysis tools - awk (Linux)

- Puppet Detailed centralized configuration management system (Server)

- Ubuntu 15.04 installed Nvidia Quadro series graphics driver (Linux)

- How MySQL tracking sql statement (Database)

- VMware virtual machines to install virt-manager unable to connect to libvirt's approach (Linux)

- CoreOS use register mirror to build private warehouse (Linux)

- Python exception summary (Programming)

- Qt shared memory interprocess communication (Programming)

- How to add a new hard disk without restarting the CentOS 7 / RHEL 7 virtual machine (Linux)

- Cobbler Add custom YUM source (Linux)

- Lenovo Ultrabooks Ubuntu system can not open the wireless hardware switch solutions (Linux)

- Inject script commands manually annotated summary (Linux)

- Oracle database file path changes (Database)

 
         
  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:      
 
- MySQL to manage multiple instances of method (Database)
- linux server security (Linux)
- CentOS6.7 text installation system (Linux)
- Linux environment variable configuration and save places (Linux)
- Linux package management (Linux)
- Boost-- time and date - (1) timer library introduction (Programming)
- CentOS ClamAV antivirus package updates (Linux)
- Linux dual physical network card set to a virtual NIC (Linux)
- Configuring automatic mail GAMIT under CentOS system (Linux)
- Security: Unix operating system intrusion tracking Strikes Back (Linux)
- Linux command line to put on your coat GUI (Linux)
- Those things packaged using Gradle to Android (Programming)
- LAN in Ubuntu shared folders to Windows (Linux)
- Fedora 22 installation and configuration optimization (Linux)
- RMAN backup file is much larger than the size of the database Cause Analysis (Database)
- Computer security perimeter recommendations (Linux)
- PostgreSQL export data dictionary documents (Database)
- DELL D630 Wireless LAN Driver Installation CentOS6 (Linux)
- Configuration based on open source Lucene Java development environment (Server)
- Linux installation JDK1.6 rpm.bin assembly (Linux)
     
           
     
  CopyRight 2002-2020 newfreesoft.com, All Rights Reserved.