Discover java performance tuning and optimization, include the articles, news, trends, analysis and practical advice about java performance tuning and optimization on alibabacloud.com
Java is not just a language concept, in addition to the definition of language, there are Java Virtual machine specifications (that is, compiled bytecode format and memory model) and memory recycling mechanism.
1, in the Java language Code layer, provides the syntax rules.
2, in the class byte code compilation, the memory model as well as the byte code instru
Performance | Optimization One, general article
The issues discussed in "common article" are appropriate for most Java applications.
1.1 Create an instance of a class without the new keyword
When you create an instance of a class with the new keyword, all constructors in the chain of the constructor are invoked automatically. But if an object implements the
Creation of 1.Java performance optimization objectsFor every Java programmer knows how to create objects, but do you know how to create them to improve the performance of your application?Do you know the application rules for creating objects?(1). To avoid creating objects i
High-performance ASP. NET Site build series Article Directories
During this time, I reorganized the series of articles, and the previous introduction to performance optimization was not very clear. It can be said that starting from this article, it is the beginning of a complete series.
The topics in this chapter are as follows:
General
, even if you add a CPU and a thread, the performance does not increase linearly. There is an Amdahl theorem to illustrate this problem:
F indicates the serialization ratio and N indicates the number of processors. It can be seen that only serializing can be minimized to maximize scalability. The key to reducing serialization is to reduce lock competition. When many parallel tasks are attached to the acquisition of locks, they are serialized.
Excessi
Code optimization for Java Program performance optimizationString part:We need to know about this part of string StringBuffer StringbuliderString is an immutable sequence of characters, optimized for constant pools, and the class is finalThe invariance of string refers to the immutable character of a string object once created.Constant pool
reuse its subprocess-that is, the next HTTP request will reuse Apache's subprocess and reuse the same MySQL link. In theory, this sounds very good. But from personal experience (and most people), this function creates more trouble. Because, you only have limited number of links, memory problems, file handles, and so on. And, Apache runs in an extremely parallel environment, creating a lot of processes. This is why this "permanent link" mechanism is not working well. Before you decide to use per
Performance Optimization of Java programsLet's take a look at another common Java class ?? Java. util. vector. Simply put, a vector is an array of Java. Lang. object instances. A vector is similar to an array. Its elements can be
another class, because all constructors in the constructor chain are called automatically when an object is created with the new keyword.Here's a note that when you set an initial value for a member variable but need to call another method, it's best to put it in a method such as initxxx (), because calling a method assignment might throw a null pointer exception because the class has not yet been initialized, public int state = This.getstate ( );XI. Traversal of Haspmapmapusing the hash value
* 100 * 10
(Note: Because a single time consuming depending on the different machine configuration, the previous table related to the time to use the number of processing to explain)
The performance optimization of the code is to minimize the number of instances, initializations, comparisons, and increases of the cyclic variables I, j, K, and not to introduce other possible operation time.
3
StringBuilder (21), switch off
New StringBuilder (21), switch on
0.958 sec
0.494 sec
0.663 sec
0.494 sec
Summarize
When converting to a string, avoid using "" strings for conversions. Use the appropriate String.valueof method or the ToString (value) method of the wrapper class.
Try to use StringBuilder for string concatenation. Check the old code and replace it with the stringbuffer that can be replaced.
Use the-XX:+OPTIMIZE
commonReal topic classes and interfaces as in the previous example, no longer postedJavaassist 's dynamic agent has two implementations, one using a proxy factory and one using dynamic java code to generate bytecodeThis is where the code is directly posted:Picture upload failed ~ ~ ~Ps: The above instance method handles the class in the logical processing class , the Real topic class and interface are the same as the above exampleThe proxy factory sp
: Google search: BlackBerry Best Practices site:docs.blackberry.com
Best Practice:writing Efficient Code (5.0)
Best practice:writing Efficient Code (4.6)
8. General Java Memory Usage issues
Strings are used, objects that are no longer used are set to null, reusing objects as much as possible rather than repeatedly generating and discarding large numbers of small objects.
9. J2ME Performance
Database Tuning tutorial (4) Explain performance analysis command, tuning explain
In the previous chapter, we learned how to find slow queries and record statements into logs. How can we know where statement problems occur after slow queries are found. This chapter describes how to use the database performance analysis
, connection pooling (C3P0, DBCP)11, Database data classification storageStore frequently-visited data and low-frequency data to separate partitions. Even to different database servers to allocate hard disk I/O and system I/O in a fit.12. Cache PolicySuppose that some data is often read from the database. At the same time, these data do not change very often, the data can be cached in the system, the use of the direct reading of the cache. Without frequent access to the database to read data.Cac
Skills | performance | Optimization three, GUI article
This section covers the application of the graphical user interface (applets and general applications) to use AWT or swing.
3.1 Compressing class files with jars
A Java archive (JAR file) is a file that is compressed according to the JavaBean Standard and is the primary way and recommended way to publish J
Technology Discovery:Recently tested colleagues shared a software Java ISUALVM for running performance monitoring with Java, and after jdk1.6 it appeared and lurked in the bin directory,This simple and powerful tool has not been discovered until now because the version update information is rarely followed.Technical Introduction:The VISUALVM is a visualizer that
combinations use different queries: 1, lazy= "true" fetch = "select", using the delay policy, start querying only the main object, the association object will not query, only when the use of the time will be issued SQL statements to query; 2, lazy= "false" fetch = "select", do not use a delay policy, while querying out the main object and associated objects, resulting in 1+n SQL. 3, lazy= "true" or lazy= "false" fetch = "join", the delay will not work, because the use of an outer join query, wh
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.