473,803 Members | 3,616 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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)*370000 0 = 78
MB ((17*sizeof(cha r) + sizeof(int)) * number_of_times _i_do_the_hashi ng). 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 1736
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.publi c.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)*370000 0 = 78 MB ((17*sizeof(cha r) + sizeof(int)) *
number_of_times _i_do_the_hashi ng).
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.goo glegroups.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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
22332
by: Matthias Käppler | last post by:
Hi, I need to store objects of a FileInfo class containing information about a specific file. I can uniquely identify these files by their serial number. I thought it would be a good idea to use a hash map so I can access the file information in constant time, without having to iterate over a (possibly very large) list of files. As far as I know, std::map does not hash its entries (I guess it takes O(nlogn) time to find an entry)....
22
4652
by: VK | last post by:
A while ago I proposed to update info in the group FAQ section, but I dropped the discussion using the approach "No matter what color the cat is as long as it still hounts the mice". Over the last month I had enough of extra proof that the cat doesn't hount mice anymore in more and more situations. And the surrent sicretisme among array and hash is the base for it. I summarized all points in this article:...
12
3207
by: wxs | last post by:
Many times we have a bunch of enums we have from either different enums or the same enum that will have various numeric values assigned. Rarely will there be collisions in numbering between the enums. These enums you might imagine would be like OrderPrice=27, OrderQuantity=50, OrderSide=62. There may be a lot of these. So normally what we would have to do is store these in hash table so hashtable=value could be set with the value....
2
2531
by: Ravi | last post by:
Hi, I am working on a winform app. I need to use an object which can store some information(key/value pairs) and also can be acessed by multiple threads(read/write). From what I heard Hash table is best suited for it. My question is Why hash table. why can't we use an array. I thought hash table uses more memory than array. Correct me if am wrong.
21
3232
by: Johan Tibell | last post by:
I would be grateful if someone had a minute or two to review my hash table implementation. It's not yet commented but hopefully it's short and idiomatic enough to be readable. Some of the code (i.e. the get_hash function) is borrowed from various snippets I found on the net. Thee free function could probably need some love. I have been thinking about having a second linked list of all entries so that the cost of freeing is in proportion to...
6
16883
by: fdmfdmfdm | last post by:
This might not be the best place to post this topic, but I assume most of the experts in C shall know this. This is an interview question. My answer is: hash table gives you O(1) searching but according to your hash function you might take more memory than binary tree. On the contrary, binary tree gives you O(logN) searching but less memory. Am I right?
13
2536
by: ababeel | last post by:
Hi I am using a calloc in a hash table program on an openvms system. The calloc is used to declare the hash table char **pHashes; pHashes = calloc(hash_size,sizeof(char *)); //hash_size = 101 and then later on when it is half full i do the following char **newHashes; if(newHashes)
139
14249
by: ravi | last post by:
Hi can anybody tell me that which ds will be best suited to implement a hash table in C/C++ thanx. in advanced
13
5087
by: Chad | last post by:
Excercise 6-5 Write a functon undef that will remove a name and defintion from the table maintained by lookup and install. Code: unsigned hash(char *s); void undef(char *s)
23
5743
by: raylopez99 | last post by:
A quick sanity check, and I think I am correct, but just to make sure: if you have a bunch of objects that are very much like one another you can uniquely track them simply by using an ArrayList or Array, correct? An example: create the object, create an array, the stuff the object into the array. Later on, assume the object is mutable, the object changes, but you can find it, if you have enough state information to uniquely identify...
0
9703
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10316
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10295
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
7604
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6842
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5500
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5629
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4275
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2970
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.