The basic idea of the object pool chemical object pool is: saves the objects that have been used. When this object needs this object, it will be reused to a certain extent, reducing the overhead of frequent creating objects. The object used to act as a "container" that saves the object is called "object pool" (Object Pool, or Pool).
For objects (such as String), there is no need to perform any processes before repeated use; for stateful objects (such as StringBuffer), they need to return them to the state when they are just generated. Due to the constraints of the conditions, the operation of restoring an object cannot be implemented, and this object is abandoned and the newly created instance is used.
Not all objects are suitable for pooling - because the maintenance target pool also causes certain overhead. Chili is poolized for objects that are not overwritten during the generation, but may appear "The overhead of the maintenance target pool" is greater than "cost of generating new objects", thereby reducing performance. However, for a significant object, the poolization technology is an effective strategy to improve performance.
When do you want to use objects to use objects, it is to reduce the overall performance by reducing the number of objects generated by reducing objects, thereby increasing overall performance. However, the poolization processing itself should also pay the price, and therefore, it is not suitable for use with object cells.
For a lightweight object similar to POINT, after the pool is processed, performance is decreased, so it is not advisable;
For medium-level objects like HashTable, the performance is basically unchanged, and it is generally not necessary to pill (Pihua makes the code complex, and the difficulty of maintaining maintenance);
For a heavyweight object similar to JPANEL, after the pool is processed, the performance has risen, and the pool is considered.
According to the method of use, the actual situation may be slightly available with this measurement result. On the virtual machine with high machines and technologies, the range of non-pool-free objects may be larger. However, for objects such as networks and databases, there is still a need for poolization.
Basically, the object pool is appropriate when the operation of repeating the operation of a certain object is a key factor affecting performance. If the performance of the pool can be improved, it is not important, or the object pool technology is not used to maintain the conciseness of the code, and the performance of better hardware and better virtual machines can be improved.