Sets are not necessarily faster than maps.  For example, HashSet delegates to an 
internal HashMap for storage.  Additionally, a map must be used in order to coalesce 
equivalent objects to a single instance.  All a set can tell you is whether a given 
object is in the set -- not what instance was first added to the set.  Using a map as 
a set allows you to retrieve the original value.

Joel

-----Original Message-----
From: Christian Pesch [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, March 05, 2003 1:27 PM
To: Joe Consumer
Cc: [EMAIL PROTECTED]
Subject: Re: Swing and Memory Issues


Joe Consumer wrote:

>What kinda memory problems are you having?  30,000
>rows and 80 columns is 2.4 million cells which is
>going to be a lot of memory.
>
One could reduce the memory footprint by
putting a layer between the TableCellRenderer
and the TableModel, which only fetches the
data for the currently displayed rows and
columns. I've done that with success.

> I reduced a
>considerable amount of memory usage by collapsing
>duplicate uses of memory.  When you read stuff out of
>a database or file you can get lots of objects that
>are value equivalent (.equals()), I collapsed those
>references by passing all my data through a HashMap.
>hashMapInstance.put( value, value );  Then retrieving
>it again with hashMap.get( value );  That way all my
>objects ended up collasping into one reference for
>.equals().  I reduced my memory usage by 60%.
>
Thats an implementation of the flyweight
pattern, but why do you take the extra effort
to pass all your data through a Map? An even
if you do it, isn't a Set the better structure
than a Map?

-- 
Christian Pesch - Product Maturity Manager
CoreMedia AG - http://www.coremedia.com - 0700-COREMEDIA



_______________________________________________
Advanced-swing mailing list
[EMAIL PROTECTED] http://eos.dk/mailman/listinfo/advanced-swing
_______________________________________________
Advanced-swing mailing list
[EMAIL PROTECTED]
http://eos.dk/mailman/listinfo/advanced-swing

Reply via email to