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

What are the tuning techniques of JVM?

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

Share

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

This article is to share with you what JVM tuning skills have, the editor thinks it is very practical, so I share it with you to learn. I hope you can get something after reading this article. Let's take a look at it.

How much do you know about JVM tuning, here are a few, for example, to upgrade the JVM version, if you can use 64-bit, use 64-bitJVM. There is basically nothing to explain, it is very simple to upgrade JVM to the * version. If you still use JDK1.4 or even earlier JVM, the first thing you need to do is upgrade.

Summary of JVM tuning skills

Cut the crap. The following methods have been collected from various aspects:

1. Upgrade the JVM version. If you can use 64-bit, use 64-bitJVM.

There is basically nothing to explain, it is very simple to upgrade JVM to the * version. If you still use JDK1.4 or even earlier JVM, the first thing you need to do is upgrade. Because JVM from 1.4-> 1.5-> 1.6 is not just a version number upgrade, or just added a bunch of new language features, it's as simple as that. Instead, major improvements have been made in JVM, with every version upgrade with a huge performance upgrade. Especially when SUN realizes that java is all his bosom friend (exaggeration, but even the stock number has been changed to JAVA, hehe). If you often visit SUN's JVM forum, you will find that there are actually so many problems on JVM. If you can't upgrade to 1.6 for a variety of reasons, you can upgrade to that version.

two。 Select a correct GC (GargageCollection).

Because when the JAVA program GC, the current program will be stopped. Especially in FullGC, it will stay for a long time. Generally speaking, it is difficult for GUI programs to accept (think about the time when Eclipse is paused). After JAVA5, you began to bring several kinds of GC, and you can choose one that suits you. There are four SerialCollector,Parallelcollector,ConcurrentCollector,TrainCollector (obsolete). Parallel collection is used in the next few times, so it is theoretically more efficient (you are required to have more than 2CUP, but now multicore is becoming popular, hehe). Tip: after changing the type of GC, it is necessary to properly increase the amount of memory of JVM.

3. Set the memory size correctly. Each area (young,old,perm) in the JVM heap is sized correctly when JVM tuning is performed.

This is the most difficult adjustment because it directly affects the efficiency of GC. And because the type of each program is not used, there is no general data. In addition to a few common rules, you need to use tools (jstat,jvmstat,jconsole, etc.) to adjust carefully. Several common guidelines are mentioned below. You usually use a few parameters to adjust-Xms-Xmx-XX:MaxPermSize.

Increasing the value of-XX:NewRatio (NewSize/MaxNewSize) reduces the number of younggc, but increases the time of oldgc.

3.2The method of adding normal GC (decreasing FullGC). Increase the size of the young area (* 40%) and oversize the Survivor area. Make more object stay in younggen.

4. Reduce the usage of classes, pay attention to the load and unload of classes, and reduce the number of JSP pages.

Classes are actually objects, which are allocated directly to the perm area, and even FullGC is rarely collected. JSP will also be assigned to the perm area, with the same effect. If the perm is too large and exceeds the XX: MaxPermSize value, an OutOfMemoryError:PermGenspace exception occurs. The workaround is to increase the-XX: MaxPermSize value.

5. Avoid using-Xnoclassgc when JVM tuning

6. If it is a RMI program, you should pay attention to adjust the time of RMIDGC.

◆ the following are a few things you should pay attention to when writing programs. It can also reduce GC and improve JVM performance.

1. Do not use the System.gc () method.

Because it produces FullGC.

two。 Allocate as few large temporary objects as possible (short life cycle)

It may be assigned directly to the old area, and the old area will only be collected when there is FullGC.

3. Avoid using the finalize () method.

Finalize () increases the burden on GC, using java.lang.ref instead.

The above is what JVM tuning skills have, and the editor believes that there are some knowledge points that we may see or use in our daily work. I hope you can learn more from this article. For more details, please follow the industry information channel.

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