Analysis of memory overflow exceptions in java

Source: Internet
Author: User
First, use the jdk built-in tool jmap dumping (dump) java memory heap data to local files. The jmap dump command format is as follows:
Jmap-dump: <dump-options> <pid>
<Dump-options> indicates the dump option, and <pid> indicates the process ID of the java application that requires dump.
Dump-options can have the following three parameters, separated by commas:
Live: only dump active objects. If not specified, dump all objects
Format = B, byte stream format
File = <file>, <file> is the storage path of the dump file.
The following is an example of the dump command:
Jmap-dump: format = B, file = heap. bin 8023
 
After dump is complete, use the Eclips tutorial e Memory Analyzer to open the dump file for analysis. Eclipse Memory Analyzer is a java Memory heap dump file analysis tool that can generate Memory analysis reports (including Memory leakage Leak Suspects ). The following figure shows the Top Consumers chart after the analysis is complete:
When you see these two charts, the problem becomes clearer. The data node com. sleepycat. je. tree. BIN in berkeley db occupies a large amount of memory, leading to memory overflow. To improve access efficiency, berkeley db caches a large number of nodes. The cache size limit can be set in EnvironmentConfig. The default value is 60% of the jvm memory size limit. In this application, five EnvironmentImpl are used, and the cache size is not set separately, the total cache limit is 300% of the jvm memory limit (the BIN node in the chart occupies 94.55% of the memory), far exceeding the java memory limit. As the service runs, more and more cached data leads to memory overflow errors. Therefore, you can set an appropriate cache size limit for each EnvironmentImpl to avoid memory overflow again.

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.