Groups keyboard shortcuts have been updated
Dismiss
See shortcuts

Footprint of google collections

9 views
Skip to first unread message

Hein Meling

unread,
Dec 20, 2009, 7:21:20 PM12/20/09
to Google Collections Library - users list
Ciao,

I'm building a simulator that aims to use space sparingly, and I want to use Multimap to store stuff, since it is such a nice abstraction ;-)

I was wondering if the google collection implementation (Multimap specifically) is designed to have a small footprint as possible or, if that is a secondary objective? (haven't looked at the code)

I'm mostly worried about the footprint of many instances of HashMultimap. How is the footprint compared to a HashMap combined with a collection to simulate the same behavior as Multimap?

Also, would it make sense for me to extract the relevant interfaces and classes directly into my project rather than using the provided jar to save space. I'm guessing that only the classes that I actually instantiate will be loaded and take up memory, but I'm not sure... In any case, I'm mostly worried about the large number of instances that I need or want to use in my simulator.

Could anyone give me some input on these matter?

Thanks!

All the best,

:) Hein


Jared Levy

unread,
Dec 21, 2009, 6:03:03 PM12/21/09
to Hein Meling, Google Collections Library - users list
Most of the library's multimaps are implemented as a Map<K,
Collection<V>>, where the Collection is a HashSet for a HashMultimap
and an ArrayList for an ArrayListMultimap. The other members variables
have a small fixed size. Note that LinkedListMultimap and
LinkedHashMultimap require more memory to store the iteration order.

To reduce memory usage, use an ArrayListMultimap, since ArrayLists are
smaller than HashSets.

> --
> Google Collections Library - users list
> http://groups.google.com/group/google-collections-dev?hl=en
>
> To unsubscribe, send email to:
> google-collections...@googlegroups.com

Reply all
Reply to author
Forward
0 new messages