Java JVM Memory tuning (from Xiao Qiang public lesson)

Source: Internet
Author: User

Java JVM memory tuning

JDK:java Development Kit

Jre:java Runtime environment, run the Java program you write

JVM:java virtual machine,. class file running on virtual machine

How to choose the right Java virtual machine

" Choose a stable jdk(with new, new features)

"" according to the platform and application, select the appropriate vendor JDK. HP- UX can only choose the jdk,aix only IBM jdk;windows ,linux can choose SUN Jdk;solaris platform best to use SUN JDK; Open Source JDK , very little is being used in the production environment

"" 32bit or 64bit

"" memory requirements are small, CPU- Intensive Applications Select 32bit

"" Big Memory application is selected 64bit(breakthrough 4G memory limit, throughput slightly higher)

Java Memory

"" Java memory = heap memory + non-heap memory

"" heap memory = Young generation + old generation -xms ( min )-xmx ( max .)

"" Non-heap memory = Permanent generation + other -xx:pemsize-xx:maxpermsise

The JVM in the latest java8 has removed the permanent generation, replacing it with the metaspace meta-space

Typical memory problems

"" OOM VS ML

"" OOM Memory Overflow, is the program when requesting memory, there is not enough memory for its use

"" ML memory leak, refers to the program after the application of memory, unable to free the requested memory space, resulting in this memory has been occupied

" The final performance is basically the same, usually memory leaks ML will eventually cause an OOM error. In practical applications do not too tangled or draw a distinction, each phenomenon is related.

What is the area where memory problems often occur

"Heap heap memory and pemanent area

"" JVM process Memory and third-party local code used by Java

Like what:

"" Java heap has insufficient memory to allocate new objects or blocks of memory

"" Java heap is full of memory, but s0,s1,eden,old area distribution unreasonable

How to prevent memory-related problems

System aspects:

"," "Enough physical memory

"The Best heap settings

"" is stable OS,jdk , etc.

"" The appropriate garbage collection algorithm strategy

Code aspects:

" don't put a lot of objects into the session . "

the resources that have been exhausted must be released, for example IO,file,jdbc

"" do not violate the specifications of the Java EE

"" reasonable amount of data obtained from the database (can be taken from the cache from the cache)

"" Good Code Habits


Java JVM Memory tuning (from Xiao Qiang public class)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.