Home IT Linux Windows Database Network Programming Server Mobile  
           
  Home \ Programming \ How to identify memory leaks in Java     - Java precision four operations (Programming)

- Raspberry Pi configuration wireless hotspot (Linux)

- Linux firewall security (Linux)

- CentOS install Redis (Database)

- Git Getting Started tutorial (Linux)

- Setting Lns firewall against ARP attacks (Linux)

- Oracle rebuild index script (Database)

- Camouflage Nginx Web server version to prevent invasion (Linux)

- Ubuntu 32 compile Android 4.0.4 Problems (Linux)

- CV: Linux command displays the progress of the run command (Linux)

- CentOS6.3 build a Python 3.3 environment to access Oracle 11gR2 (Database)

- MySQL Error Code Complete (Database)

- RabbitMQ tutorial examples: RabbitMQ installation under Windows (Linux)

- Vi (Vim) keyboard map and its basic commands (Linux)

- Raspberry Pi 2 to install the latest version of the FPC and Lazarus 1.5 (Linux)

- Let your PHP 7 faster (GCC PGO) (Linux)

- Android Delete project useless resource file (Programming)

- C language preprocessor command (Programming)

- Use rfkill soft-switching and Bluetooth wireless capabilities in Linux (Linux)

- CentOS 6.4 RPM install MySQL-5.6.22-1 (Database)

 
         
  How to identify memory leaks in Java
     
  Add Date : 2017-01-08      
         
       
         
  On Martin Gutenbrunner worked at Ruxit, it has 10 years of Java Web application architecture and management experience. Recently, he wrote a Java memory leak identification to share relevant experience in Dzone, translated by OneAPM engineer.

The following is a translation

Java developers know, Java garbage collection mechanism to automatically use application memory to keep clean and healthy. However, some people may not know is that even with the garbage collection mechanism, Java is still possible memory leak risk. If you get the following error code:

java.lang.OutOfMemoryError: Java heap space
If you're sure is insufficient memory allocation, then the following code can increase the available memory for the application:

java -Xms -Xmx
However, for the memory leak is doing is a temporary solution, can only play a role in mitigation.

Identify memory leaks

Before deployment into the production environment to check whether there is a memory leak problem it is necessary. Here we can make a preliminary judgment by the garbage collector indicators.

After GC as memory usage continues to rise, then it may have a memory leak problems, such as above this figure, the code can be viewed GitHub (https://gist.github.com/dpryden/b2bb29ee2d146901b4ae). But on the map as a linear memory as an increased likelihood in reality it is very small, Figure Old Gen, and GC suspension times or Eden Space and Survivor space usage and insufficient to identify memory leaks.

Narrowing

To find out the reasons for memory leaks the moment there are already many tools are available, such as JVisualVM or jStat. These tools are comes with the JDK, so we can use at any time. In addition to the identification of some common internal Java classes, some users also need to recognize custom tired.

Performance Optimization

In the daily development process, as long as the GC does not affect the performance, developers will not to pay attention to memory settings in the configuration. Thus planting the potential pitfalls: the problem is not only because the memory overflow and leak, GC time is too long will also cause this problem. For example, the following figure GC takes up 16% of the CPU.

Heap Settings

Heap too small to cause frequent GC, thus not difficult to imagine the scene: the increase GC will consume more CPU, while JVM GC will be frozen in time, leading to a poor performance. Overall, Heap too small, although the GC time is shorter, but will become more frequent.

Heap too large lead time GC side. GC does not happen often, but once triggered, then the VM will be frozen for a long time.

Thus, if a memory leak in this case, because in the final JVM out of memory before the collapse, GC will be very frequent or particularly long time.

GC version

From Java 6 began, GC changed a lot. Java 7 introduced G1GC as an alternative CMS GC, whereas in Java 9 in G1GC has become the default choice. Java 8 are removed PermGen Space, the data previously stored in PermGen Space will be replaced in the local memory or stored on the stack.
     
         
       
         
  More:      
 
- Lenovo E431 notebook CentOS system is installed wireless network card driver (Linux)
- 10 Codes of good practice PHP (Programming)
- Using a proxy method under Linux terminal (Linux)
- ActiveMQ5.11.1 and JDK version matching relation (Linux)
- Linux Getting Started Tutorial: / var / spool / clientmqueue fill the root directory (Linux)
- Docker ecosystem security is gradually maturing (Server)
- Why not use the ifconfig command under RedHat Linux 5 (Linux)
- The hashcode method of Java (Programming)
- MySQL use the integer type (Database)
- Ubuntu install image browser and manager Phototonic 1.6.17 (Linux)
- Linux crontab command format example (Linux)
- How to use the internal network IP forwarding to connect to the Internet on Linux (Linux)
- Varnish configuration language VCL and its built-in variables (Server)
- Oracle user lock how to know what causes (Database)
- Fatal: unable to connect to github.com problem solving (Linux)
- How to recover deleted files in Linux systems (Linux)
- Java Timer (regular calling, to achieve a fixed time to perform) (Programming)
- PostgreSQL-XL installation and deployment (Database)
- The maximum subsequence algorithm and optimization problems (Programming)
- init level settings for Linux / etc / inittab file into six (restart) or does not support the level of solution (Linux)
     
           
     
  CopyRight 2002-2016 newfreesoft.com, All Rights Reserved.