Compression Common object pointer (compressedoops) and compression class pointer (compressedclasspointers) __JVM optimization for JVM optimization

Source: Internet
Author: User
Tags memory usage

Problem Description

Java programs deployed in the server (CentOS 64-bit) run, often encounter Oom, the server killed the Java main process. For the sake of prudence, the decision to optimize the JVM and reduce memory usage was not followed by an overbearing method of closing the Oom (a detailed analysis of the Linux kernel oom mechanism).

Solving Method

Referring to the compression of the JVM optimizations in the normal object pointer, on 64-bit machines, the 64-bit JVM consumes 1.5 times times more memory than 32-bit, because the object pointer doubles (wider addressing) under the 64-bit schema. Fortunately, starting with JDK 1.6 update14, the bit JVM has formally supported the-xx:+usecompressedoops, a new parameter that can compress the pointer and save memory footprint.

When you test setting-xmx32g on a 64-bit server, refer to the description in Enable-xx:+usecompressedoops by default,-xx:+usecompressedoops and-xx:+ Usecompressedclasspointers will fail, so the maximum JVM heap space is set to 31g, and the relevant tests are as follows:

Test 1:-xmx32g-xx:+usecompressedoops settings not in effect

-xmx31g-xx:+usecompressedoops settings take effect

[Rgf@datanode02 mqpf]$/home/rgf/java/jdk1.8.0_151/bin/java-server-xmx32g-xx:+usecompressedoops-xx:+ Usecompressedclasspointers-xx:+printflagsfinal Oops | grep Oops
Java HotSpot (TM) 64-bit Server VM warning:max heap size too large for compressed Oops
     bool Usecomp Ressedoops                        : = False                               {lp64_product}
Error: Main class cannot be found or cannot be loaded Oops
[Rgf@datanode02 mqpf]$/home/rgf/java/jdk1.8.0_151/bin/java-server-xmx31g-xx:+usecompressedoops-xx:+ Usecompressedclasspointers-xx:+printflagsfinal Oops | grep Oops
     bool Usecompressedoops                        : = True                                {lp64_product}
Error: Main class cannot be found or loaded Oops

Test 1:-xmx32g-xx:+usecompressedclasspointers settings not in effect

-xmx31g-xx:+usecompressedclasspointers settings take effect

[Rgf@datanode02 mqpf]$/home/rgf/java/jdk1.8.0_151/bin/java-server-xmx32g-xx:+usecompressedoops-xx:+ Usecompressedclasspointers-xx:+printflagsfinal Oops | grep pointers
Java HotSpot (TM) 64-bit Server VM warning:max heap size too large for compressed Oops
     bool Compressedclasspointers               : = False                               {lp64_product}
Error: Main class cannot be found or cannot be loaded Oops
[Rgf@datanode02 mqpf]$/home/rgf/java/jdk1.8.0_151/bin/java-server-xmx31g-xx:+usecompressedoops-xx:+ Usecompressedclasspointers-xx:+printflagsfinal Oops | grep pointers
     bool Usecompressedclasspointers               : = True                                {lp64_product}
Error: Main class cannot be found or loaded Oops




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.