classpath-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[cp-patches] FYI: Implemented an ObjectPool


From: Roman Kennke
Subject: [cp-patches] FYI: Implemented an ObjectPool
Date: Fri, 01 Jul 2005 12:52:42 +0200

I implemented and added an ObjectPool class. This should help improve
performance in Swing (and other areas). In Swing we make heavy use of
Point Dimension and Rectangle. Usually these objects are created to wrap
some integer values and are discarded quickly. This would create
overload for creating and garbage collecting these instances which is
not necessary if these objects are cached. Instead of caching such
objects in private instance fields, I think it would be much better to
use an object pool like this.

Please keep in mind that you must take care when you use the ObjectPool.
While it is useful it also has one drawback: you have to explicitly
release the object back to the pool (in the current implementation). So
you should be fairly certain that the pooled object is not stored in a
different location.

Also, you have to manually take care of the actual state of the pooled
object.

Of course, the ObjectPool is not limited to be used in Swing.

On how to use the pool, please review the API docs of that class.

2005-07-01  Roman Kennke  <address@hidden>

        * gnu/classpath/ObjectPool.java:
        New class. This can and should be used to cache throwaway
        objects like Rectangles, Points and Dimensions. Of course the
        use of this class is not limited to this cases.

/Roman

Attachment: ObjectPool.diff
Description: Text Data


reply via email to

[Prev in Thread] Current Thread [Next in Thread]