classpath
[Top][All Lists]
Advanced

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

Re: Duplicate object prevention policy


From: Stephen Crawley
Subject: Re: Duplicate object prevention policy
Date: Wed, 30 Nov 2005 12:55:06 +1000
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.6) Gecko/20050319

Jan Röhrich wrote:

Hello list,

imagine the following case: A method supports the lookup of objects
using a name -> object mapping. The objects are stored in a map but can
easily be newly created instead of performing a real lookup. Shall we
perform this real lookup even if the newly created object is equal to
the original object in terms of Object.equals().


The theoretical answer depends on lots of things, such as:

1) the probable number of times that the method will be called, 2) the likelihood that the lookup (if implemented) will succeed,
 3) the cost of creating the object,
 4) the cost of the name lookup is,
 5) the incremental GC cost if duplicate copies of the object become
    garbage,
6) the incremental GC cost if the mapping data structure keeps otherwise garbage objects alive, 7) the incremental GC cost if the application keeps duplicate
    copies of the objects alive,
 8) the (speculative) cost of using obj.equals(obj2) versus obj == obj2
    if we could guarantee that objects are ONLY created via the method,
 9) etcetera
And all of these depend on the nature of the objects and the way that they
are used in a typical application.  In short, there are no general answers.

-- Steve






reply via email to

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