Home PC Games Linux Windows Database Network Programming Server Mobile  
  Home \ Programming \ Fundamentals of the Java virtual machine memory management principles     - To batch create users under Linux (Linux)

- To install and use Docker under linux (Server)

- Linux system network security tools sudo Introduction (Linux)

- Use Bosh deploy CloudFoundry problems encountered on OpenStack (Server)

- Red Hat Enterprise Linux Server 6.5 installation GCC 4.9.2 (Linux)

- Those functions under Linux you do not know the df command (Linux)

- Oracle 11g RMAN virtual private directory (Database)

- Linux print file and send mail (Linux)

- grep command usage (Linux)

- Orabbix binding Python send graphical reports (Linux)

- Select helps secure the system network management tools (Linux)

- Three kinds of binary tree traversal recursive and iterative solution (Programming)

- RHEL7 unattended automatic installation DHCP + TFTP + SYSLINUX + TFTP + Kickstart (Linux)

- grep regular expression (Linux)

- How to Install Suricata IDS on a Linux system (Server)

- System Safety: Windows and Linux platforms (Linux)

- How to manage the time and date at systemd Linux systems (Linux)

- Chrome plug-in management, online-offline installation, part of the plug presentations (Linux)

- iostat command Detailed (Linux)

- Spacewalk remove packages install the update (Linux)

  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
- How to Install Android Studio on Ubuntu 15.04 / CentOS7 (Linux)
- Some MySQL interview questions (Database)
- Varnish achieve page jump (Server)
- VMware virtual machine to use bridged mode fast Internet access (Linux)
- Using Python to find a particular file extension directory (Programming)
- Oracle ORA-01089 failure analysis (Database)
- Linux suffered SYN flood attack setting (Linux)
- JavaScript is implemented without new keywords constructor (Programming)
- How to manage KVM virtual environments with command-line tools in Linux (Server)
- Sublime Text 3 shortcuts summary (Linux)
- Nagios (centreon) monitoring LVS (Server)
- MySQL Installation Troubleshooting (Database)
- CentOS 7 x64 compiler installation Tengine 2.0.3 Comments (Server)
- Zabbix monitors Nginx status (Server)
- Ubuntu 10.10 install Oracle 10g graphic tutorials (Database)
- How to use the Linux command compress JPEG images (Linux)
- Solaris 10 nagios monitoring system (Linux)
- mysqldump MySQL command-line tool (Database)
- Linux find command to find files (Linux)
- Linux command Detailed chpasswd bulk edit user password (Linux)
  CopyRight 2002-2022 newfreesoft.com, All Rights Reserved.