Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

The cause of memory overflow in JVM and how to solve it

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

JVM memory overflow causes and solutions, many novices are not very clear about this, in order to help you solve this problem, the following editor will explain in detail for you, people with this need can come to learn, I hope you can gain something.

1. Java heap space

Frequency of occurrence: 5 stars

Cause

Unable to allocate objects in the Java heap

Increase in throughput

The application inadvertently saved the object reference, and the object cannot be recycled by GC

The application makes excessive use of finalizer. Finalizer objects cannot be immediately recycled by GC. Finalizer is called by the daemon thread that ends the queue service, and sometimes the processing power of the finalizer thread cannot keep up with the growth of the end queue.

Solution

Use-Xmx to increase heap size

Fix memory leaks in applications

2. GC overhead exceeds the limit

Frequency of occurrence: 5 stars

Cause

The Java process spends 98% of its time on garbage collection, recovering less than 2% of the heap space, and finally five consecutive (compile-time constants) garbage collections have been the same.

Solution

Use-Xmx to increase heap size

Use-XX:-UseGCOverheadLimit to remove the GC cost limit

Fix memory leaks in applications

3. The size of the requested array exceeds the virtual machine limit

Frequency of occurrence: 2 stars

Cause

The application attempts to allocate an array that exceeds the heap size

Solution

Use-Xmx to increase heap size

Fix bug in an application that allocates a large array

4. Perm gen space

Frequency of occurrence: 3 stars

Cause

The Perm gen space contains:

Name, field, method of the class

An array of objects and types related to a class

JIT compiler optimization

When the Perm gen space is exhausted, an exception is thrown.

Solution

Use-XX: MaxPermSize to increase the Permgen size

Failure to restart the application deployment application may cause this problem. Restart the JVM solution

5. Metaspace

Frequency of occurrence: 3 stars

Cause

Starting with Java 8, Perm gen is changed to Metaspace, and class metadata (called metaspace) is allocated in native memory. If the metaspace is exhausted, an exception is thrown

Solution

Increase the metaspace size by setting-XX: MaxMetaSpaceSize on the command line

Cancel-XX: maxmetsspacedize

Reduce the Java heap size to provide more free space for MetaSpace

Allocate more memory to the server

It could be the application bug, fix bug

6. Unable to create a new native thread

Frequency of occurrence: 5 stars

Cause

There is insufficient memory to create a new thread. Because the thread was created in native memory, reporting this error indicates that the native memory space is insufficient

Solution

Allocate more memory to the machine

Reduce Java heap space

Fix thread leaks in the application.

Increase operating system level restrictions

Ulimit-a

The number of user processes increases by (- u) 1800

Use-Xss to reduce the thread stack size

7. Kill a process or child process

Frequency of occurrence: 1 star

Cause

Kernel task: out of memory Terminator, which kills the process when the available memory is very low

Solution

Migrate the process to a different machine

Add more memory to the machine

Unlike other OOM errors, this is triggered by the operating system, not JVM.

8. Occurrence of stack_trace_with_native_method

Frequency of occurrence: 1 star

Cause

Native method (native method) allocation failed

Printed stack trace information, the top frame is the native method

Solution

Diagnostics using operating system native tools

Is it helpful for you to read the above content? If you want to know more about the relevant knowledge or read more related articles, please follow the industry information channel, thank you for your support.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report