Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7540877
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T07:44:51+00:00 2026-05-30T07:44:51+00:00

I have a tough problem right now. I am having a big dictionary file

  • 0

I have a tough problem right now. I am having a big dictionary file to be loaded in my program, its format basically is:

word1 val1
word2 val2
word3 val3
...
...

This file has 170k lines, and its size is 3.9MB on the disk (in plain text). In my implementation I used boost::unordered_map (hashtable) to store this data to support read-only looking up operations in my program.

Yet, after loaded into memory in runtime, the memory usage increased by 20MB due to the loading operation (I checked this via the Private Working Set Size in windows Task Manager, maybe this is not the right way to determine the memory usage? ). I know there must be some auxiliary data structures in the hashtable to store that data that will increase the memory usage, but I didn’t expect the memory size is as much as 5x than its disk size!

Is this normal? Since I have tried another version of hashmap in std extension library, and Trie structure in some other memory, none of them bring significant improvement on that issue.

So that I want to implement some space optimization over this problem. Could any one give some tips or keywords to guide me improve the space usage?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T07:44:53+00:00Added an answer on May 30, 2026 at 7:44 am

    A hash map data structure allocates much more memory than it uses at one time. This is to facilitate quick inserts and removals. When a hash table reaches a certain capacity (implementation defined, but it’s a number like 50% full, 70% full, 90% full, etc.) it will reallocate more memory and copy everything over. The point is that it allocates more memory than is in use.

    Also, the 20 MB that you see the program using is the size of all the memory your program is using, not just the one hash map.

    Furthermore, if you are using std::string or equivalent structure to store the value, you already have created a copy of half the data you are getting from the file. You’ll have one copy in the buffer you read the file to, and then another copy in the strings in the hash table.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

So hello everyone I have a big problem right now with a button that
I have some code that does custom drawing. Basically it is form fill program
I'm having a major problem with writing values into a new CSV file. I
I have a couple things going on right now. I have a form that
I am very confused right now. I have VS2008 at my job right now
I'm right now a C#/Java developer, and I've been having a great time on
I'm starting to get into PigLatin and I have a question... Right now I'm
I have a seemingly simple problem though i am unable to get my head
I have a problem of web pages being cached even though I specify that
I have tough time making this design decision. I could go with traditional new

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.