Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1063
  • Last Modified:

HashMap memory usage

Hi,

my program will do this:

- create HashMap a
- add mappings
- prune many mappings (maybe 80% or so)
- HashMap a will be stored as a property in Object b (b.hashMap)
- there will be many b objects.

I'm thinking that HashMap a might have much wasted space because of the objects that existed initially but are no longer there.

So I'm thinking about doing something like this (after pruning a):

- HashMap compactA = new HashMap(a)
- b.hashMap = compactA (instead of b.hashMap = a)

What do you think? Will this be more memory efficient? Or should I not bother?
0
ycomp
Asked:
ycomp
2 Solutions
 
petmagdyCommented:
no
b.hashMap = a;
is better if all a is needed as it is, this will involve less memory operations
0
 
objectsCommented:
I doubt you'll get much saving doing that (if any).
0
 
ycompAuthor Commented:
ok cool guys thanks.
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now