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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T16:26:06+00:00 2026-06-12T16:26:06+00:00

This is closely related to .NET Collections and the Large Object Heap (LOH) .

  • 0

This is closely related to .NET Collections and the Large Object Heap (LOH). In a nutshell, if there are more than 85K buckets, it’s automatically on LOH and when it’s released is unknown. Does anyone aware of a good implementation of IDictionary based on lists of array or something like it that prevents it from going to LOH?

  • 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-06-12T16:26:07+00:00Added an answer on June 12, 2026 at 4:26 pm

    Here’s a start of one option. I assume you can follow the pattern given to implement the other methods.

    Just change the numDictionaries to determine how it’s broken up.

    If you really need to you could make the number of dictionaries dynamic and have it add more when the existing ones get sufficiently large.

    public class NonContigousDictionary<TKey, TValue>
    //TODO make this implement IEnumerable, IDictionary, 
    //and any other relevant interfaces.
    {
        public Dictionary<TKey, TValue>[] dictionaries;
    
        private readonly int numDictionaries = 5;
        public NonContigousDictionary()
        {
            dictionaries = Enumerable.Range(0, numDictionaries)
                .Select(_ => new Dictionary<TKey, TValue>())
                .ToArray();
        }
    
        public TValue this[TKey key]
        {
            get
            {
                int hash = key.GetHashCode();
                return dictionaries[GetBucket(hash)][key];
            }
            set
            {
                int hash = key.GetHashCode();
                dictionaries[GetBucket(hash][key] = value;
            }
        }
    
        public bool Remove(TKey key)
        {
            int hash = key.GetHashCode();
            return dictionaries[GetBucket(hash].Remove(key);
        }
    
        public void Clear()
        {
            foreach (var dic in dictionaries)
            {
                dic.Clear();
            }
        }
    
        private int GetBucket(int hash)
        {
            return (hash % numDictionaries + numDictionaries) % numDictionaries;
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is closely related to another question I asked: Is there functionality that is
this is closely related to this post: Is there an onSelect event or equivalent
This question is closely related to this one but i think is more general.
This question most closely relates to the asp.net mvc3 framework. It started out as
This is closely related to Is it safe to signal and immediately close a
This is pretty closely related to another SO question. Using the example below, could
This post is closely related to another one I posted some days ago .
Preface: this question is closely related to these ones: ... - C++: Avoiding Static
I've found some answers that are closely related to this problem, but I still
This is closely related to anothewr question I have asked but since this is

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.