Java performance-How to investigate and resolve memory issues

Source: Internet
Author: User
Tags stack trace java se

JVM Memory Overflow/insufficiency/outofmemoryerror/garbage collection vicious circle is a problem that needs to be solved and is not uncommon.

Recommended to read the official T roubleshooting Guide forJava SE 6 with HotSpot VMS > troubleshooting Memory Leaks

    • The first clear question -the GC log is the most accurate way to determine the memory problem, because the nature of the Java memory problem is the GC problem
      • Heap Heap Insufficient overflow
      • Stack stacks are out of overflow
      • Perm heap Insufficient overflow-Java 8 canceled Perm
      • The vicious circle of garbage collection-note: This is almost the most common phenomenon
    • Stack stacks are out of overflow -error is Stackoverflowerror

The JVM will print out the specific Stack Trace

If the Stack is larger but not recursive, then-XSS (Server default 1024K)

If Stack Trace shows recursion, then modify the code

    • Perm heap Insufficient overflow -OutOfMemoryError with PermGen space

Big-xx:maxpermsize, like 768m.

    • Heap heap Insufficient overflow- OutOfMemoryError with Heap Space.

Solution: Adjust the-xmx, if large enough to debug-refer to the following debug HEAP

    • The vicious circle of garbage collection- Note: This is almost the most common phenomenon

Phenomenon:

JVM does not correspond, memory basic consumption, analysis GC log, will see spent a long time to do FULLGC, released a bit of memory, and quickly need to FULLGC, such as 10 seconds to do fullgc,1 seconds and then need to FULLGC and then 10 seconds to complete FULLGC, repeated so.

Resolution: Adjust the-XMX, or debug-refer to the debug HEAP below

    • DEBUG HEAP-It is recommended to catch heapdump and then analyze
      • Crawl Heapdump-many methods, but commonly used as follows (note for non-IBM Java)

-xx:+heapdumponoutofmemoryerror-xx:heapdumppath=/path

--Configuration parameters memory overflow when automatically crawl, attention often memory problems appear as garbage collection vicious circle, that will not come out.

Jmap.exe-dump:format=b,file=heapdump.hprof <pid>

--Command fetching

      • Analysis Heapdump

Recommended Eclipse Memory Analyzer (http://www.eclipse.org/mat/)

Java performance-How to investigate and resolve memory issues

Related Article

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.