469,648 Members | 1,504 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,648 developers. It's quick & easy.

hash table memory question

so, i'm using the hash_map that comes with MS visual studio, and it seems to
spend an awful lot of memory. what i basiclly have is something like this:
hash_map<char*, inta;
char* b = new char[17];
int i;
//some code that initializes b and i
a[b] = i;

i do that for a huge amount of data and end up with 470 MB of memory for the
table. now, if i got it right, it should actually use (17*1+4)*3700000 = 78
MB ((17*sizeof(char) + sizeof(int)) * number_of_times_i_do_the_hashing). so,
any ides what is going on?
does hash_map use some extra memory to keep track of things and if so, is
there some other implementation of a hash table that i could use?
or am i just not seeing something?
--
You're never too young to have a Vietnam flashback
Oct 28 '06 #1
4 1527
filox wrote:
so, i'm using the hash_map that comes with MS visual studio, and it
Since your question is compiler-specific, you should consider asking
in the newsgroup for that compiler: microsoft.public.vc.language.
seems to spend an awful lot of memory. what i basiclly have is
something like this: hash_map<char*, inta;
char* b = new char[17];
int i;
//some code that initializes b and i
a[b] = i;

i do that for a huge amount of data and end up with 470 MB of memory
for the table. now, if i got it right, it should actually use
(17*1+4)*3700000 = 78 MB ((17*sizeof(char) + sizeof(int)) *
number_of_times_i_do_the_hashing).
How do you arrive at that formula?
so, any ides what is going on?
I bet folks in m.p.v.l know.
does hash_map use some extra memory to keep track of things and if
so, is there some other implementation of a hash table that i could
use?
Probably.
or am i just not seeing something?
Are you looking? If the hash_map you're using is a template (and it
looks like one), you should be able to see all of it in the header
file that you're including in your source. "Use the Source, Luke!"

V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask
Oct 28 '06 #2
filox wrote:
so, i'm using the hash_map that comes with MS visual studio,
It's non-standard - i.e., it's not part of the C++ Standard.
and it seems to
spend an awful lot of memory. what i basiclly have is something like this:
[snip]
is
there some other implementation of a hash table that i could use?
Try tr1::unordered_map.

Best regards,

Tom

Oct 28 '06 #3
"Thomas Tutone" <Th***********@yahoo.comwrote in message
news:11**********************@b28g2000cwb.googlegr oups.com...
It's non-standard - i.e., it's not part of the C++ Standard.
yeah, another question - why isn't there a hash table implementation that is
a part of Standard (as a part of STL, for example)? i mean, it's not like
hash tables are rarely used or something...
Oct 28 '06 #4
filox wrote:
"Thomas Tutone" <Th***********@yahoo.comwrote:
It's non-standard - i.e., it's not part of the C++ Standard.

yeah, another question - why isn't there a hash table implementation that is
a part of Standard (as a part of STL, for example)? i mean, it's not like
hash tables are rarely used or something...
There is, sort of. It's called tr1::unordered_map. It's part of the
C++ Library Extensions Technical Report 1, released by the C++
Standards Committee. I mentioned tr1::unordered_map in my prior reply
as well.

Best regards,

Tom

Oct 28 '06 #5

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

7 posts views Thread by Matthias Käppler | last post: by
2 posts views Thread by Ravi | last post: by
21 posts views Thread by Johan Tibell | last post: by
13 posts views Thread by ababeel | last post: by
139 posts views Thread by ravi | last post: by
13 posts views Thread by Chad | last post: by
reply views Thread by gheharukoh7 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.