resizing arrays when close to memory capacity
Posted
by
user548928
on Stack Overflow
See other posts from Stack Overflow
or by user548928
Published on 2010-12-24T18:19:26Z
Indexed on
2010/12/24
18:54 UTC
Read the original article
Hit count: 261
So I am implementing my own hashtable in java, since the built in hashtable has ridiculous memory overhead per entry. I'm making an open-addressed table with a variant of quadratic hashing, which is backed internally by two arrays, one for keys and one for values. I don't have the ability to resize though. The obvious way to do it is to create larger arrays and then hash all of the (key, value) pairs into the new arrays from the old ones. This falls apart though when my old arrays take up over 50% of my current memory, since I can't fit both the old and new arrays in memory at the same time. Is there any way to resize my hashtable in this situation
Edit: the info I got for current hashtable memory overheads is from here How much memory does a Hashtable use?
Also, for my current application, my values are ints, so rather than store references to Integers, I have an array of ints as my values.
© Stack Overflow or respective owner