Java application performance Optimization from virtual machine perspective

Source: Internet
Author: User
Tags garbage collection java se

The popularity and wide application of Java, and its mechanism based on virtual machine operation, make the performance problem more and more important. This paper analyzes Java application design from the perspective of Java Virtual machine, especially the garbage collection mechanism, and concludes several principles and habits of design and code that are very easy to be neglected. Finally, some examples are introduced to help us with the development and analysis of several main Java Profiler tools. This paper requires the reader to have some basic knowledge of Java Virtual machine, some Java design pattern and development experience. Reading this article, the reader can from the nature of Java run a good grasp of performance, in the design and coding process, follow the principles and habits summarized in this article, for improving performance, maintainability, scalability is helpful. At the same time let readers understand the use of Profiler tools to analyze the performance of Java programs.

Before you start

Java platforms are everywhere, Java EE, Java SE, Java ME, and Java Card,java are all "Java" for countless programmers, but in addition to the basic Java syntax, programmers have to have different considerations based on different platforms, Learn the characteristics of different platforms:

Environments with different platforms

Java EE runs a hardware server, operating system, the architecture of the PC where the Java SE is located (x86/x64, MAC, SPARC, etc.), the mobile phone or mobile device that the Java ME is running, and the type of smart card chip that is located on Java cards;

Characteristics of different platform virtual machines

If multithreading is supported (which seems to be unquestionable, but on the Java card platform, because computing resources are rather limited and multithreading is not currently supported), Java EE and Java SE have almost the same virtual machine characteristics, while the Java ME virtual machine (KVM) is tailored to the characteristics of mobile devices and excellent To accommodate limited physical memory and storage space, and is divided into CDC (Connected Device Configuration, networked device configuration) and CLDC (Connected Limited Configuration, networked limited device configurations, smaller devices and smart card virtual machines JCVM (Java cards VM) cut many features, such as multithreading, support for many complex data types, active garbage collection mechanisms, and so on, which even led to the clipping of Java syntax sets;

APIs for different platforms and Third-party libraries available

Java EE and Java SE are the relationships between a superset and a subset, because their computer platform and operating system are currently well compatible, while Java ME and Java Card and EE and SE are totally different, in addition to java.lang.*, part Java.io.* and other core class libraries are reserved, and other APIs and class libraries are completely different. Java.microedition.* and javax.microedition.* indicate that this is the ME platform, and javacard.* indicates that this is the Java card platform. At the same time, thanks to the popularity of EE and SE platforms and the number of developers, there is a huge amount of third-party libraries on top. In-depth understanding and mastery of platform APIs and libraries is the only way for programmers of different platforms to step in.

From this point of view, Java in different platforms, is not "a write, everywhere run", considering the design and optimization of the application, the first thing to see is on what platform, because from the above different characteristics, programming model, design patterns, and even language sets are different. Here we focus on the Java EE and SE perspectives, but there are many design, programming principles, and practices that apply to all platform programmers.

Java virtual Machines

Java virtual machines are the basis for supporting the Java language runtime, bypassing the plethora of JVM and implementation technical details, and we understand the infrastructure and are essential for application optimization. As shown in the following illustration:

Figure 1. Java Virtual Machine Architecture

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.