Browse Prior Art Database

Software Mechanism to Reuse Object Instances for Improved Performance

IP.com Disclosure Number: IPCOM000116631D
Original Publication Date: 1995-Oct-01
Included in the Prior Art Database: 2005-Mar-31
Document File: 6 page(s) / 178K

Publishing Venue

IBM

Related People

Smith, LC: AUTHOR

Abstract

A method for reusing object instances by caching previously created instances in a reinitialized state is disclosed. This improves performance when reinitializing an object takes less time than recreating it from scratch.

This text was extracted from an ASCII text file.
This is the abbreviated version, containing approximately 36% of the total text.

Software Mechanism to Reuse Object Instances for Improved Performance

      A method for reusing object instances by caching previously
created instances in a reinitialized state is disclosed.  This
improves performance when reinitializing an object takes less time
than recreating it from scratch.

      The described mechanism allows object instances to be reused
when possible, rather than being created from scratch.  The approach
is for each reusable object to define an initialize  method which can
be called to reset the instance to the state which it has when it is
initially created.  When a program no longer needs an instance of an
object, the instance is sent the reuse  method.  This causes the
instance to be reset to its initial state (using initialize) and
added to a collection of initialized instances available to the
address space.  The size of this collection can be restricted as
needed.  The collection of instances is associated with the class of
the object.

      When the program needs to reference a "new" instance of a
method, the newOrReuse  method is used instead of the new  method.
The newOrReuse  method returns either a reused instance of the object
taken from the reuse collection, or, if there are no reusable
instances available, a new and initialized instance of the object.

      Alternatively, the new method can be redefined to use the
newOrReuse  methods for classes for which it is available or active.

      Finally, when the program has completed or no longer wishes to
reuse instances, the resetReuseCollection  method is sent to the
class to remove all instances from the reuse collection, thus freeing
storage following the next garbage collection.

      Variations on the above methods are also used.  For example,
sometimes parameters are passed to the new: method.  In this case,
the newOrReuse: method would be used with parameters.

      Before and After Comparison - The following comparison shows
how this approach improves performance and reduces garbage
collection.  Note that in object-oriented systems, a large portion of
system resources and execution time can be spent on creating and
deleting objects.

      Fig. 1 shows a three phase process representing an application
creating short-lived entities.  Here, when an entity is no longer
referenced (in Phase 2), it is deleted during garbage collection.
When another instance of the object is again needed (in Phase 3), it
is created from scratch.

      Prior to the reuse approach, object-oriented systems that
handled many short-lived instances spent a large amount of system
resources on instance creation and deletion.  This is demonstrated in
Fig. 1.  Here, an instance is created.  When the instance is no
longer needed, references to the instances are deleted, the instance
is garbage collected, and when another instance of the object is
needed, the instance is created again from scratch.  The steps are
(as in...