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 6698829
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T06:37:26+00:00 2026-05-26T06:37:26+00:00

I have an application that manages a large number of strings. Strings are in

  • 0

I have an application that manages a large number of strings. Strings are in a path-like format and have many common parts, but without a clear rule. They are not paths on the file-system but can be considered like so.
I clearly need to optimize memory consumption but without a big performance sacrifice.

I am considering 2 options:
– implement a compressed_string class that stores data zipped, but i need a fixed dictionary and i cant find a library for this right now. I don’t want a Huffman on bytes, I want it on words.
– implement some kind of flyweight pattern on string parts.

The problem looks like a common one and I’m wonder what is the best solution to it or if someone knows a library that targets this issue.

thanks

  • 1 1 Answer
  • 1 View
  • 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-26T06:37:27+00:00Added an answer on May 26, 2026 at 6:37 am

    Strings are in a path-like format and have many common parts, but without a clear rule.

    In the sense that they are locators in a hierarchy of the form name, (separator, name)*? If so, you can use interning: store the name parts as char const * elements that point into a pool of strings. That way, you effectively compress a name that is used n times to just over n * sizeof(char const *) + strlen(name) bytes. The full path would become a sequence of interned names, e.g. an std::vector.

    It might seem that sizeof(char const *) is big on 64-bit hardware, but you also save some of the allocation overhead. Or, if you know for some reason that you’ll never need more than, say, 65536 strings, you might store them as

    class interned_name
    {
        uint16_t tab_idx;
    
      public:
        char const *c_str() const
        {
            return NAME_TABLE[tab_idx];
        }
    };
    

    where NAME_TABLE is an static std::unordered_map<uint16_t, char const *>.

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

Sidebar

Related Questions

In one of my projects, I have an application that manages several clients (or
I am writing an application that reads in a large number of basic user
I'm writing a DLL add-on for an application that internally has large parts written
I work on a fairly simple but large two-tier application that consists approximately 40
I have a small application that manages several git repositories similar to Github/Gitorious. Github
We have a hosted application that manages pages of content. Each page can have
We have a web application that manages inventory for our computer support group. One
I have a large number objects which are tree like structures. I have a
OK, so I have a very large multi-threaded unmanaged c++ application (server) that runs
I have a large Compact Frameworks V2.0 application that in most cases works very

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.