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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T18:34:37+00:00 2026-06-12T18:34:37+00:00

So I am developing an append-only 64-bit-ish List and Dictionary, and I’ve run into

  • 0

So I am developing an append-only 64-bit-ish List and Dictionary, and I’ve run into a memory error. I figured I would at some point, but not at 64 MBs. I find that somewhat unexpected, and am curious if someone could explain to me why it’s running into an issue at 64 MBs.

My test for my new List class is simply an attempt to create and load 8 GBs worth of bools into the List. I figured they’d suck up only ~1 bit each, so I’d get some good metrics / precision for testing my program.

Here is the output from VS:

-       this    {OrganicCodeDesigner.DynamicList64Tail<bool>}   OrganicCodeDesigner.DynamicList64Tail<bool>
        Count   536870912   ulong
-       data    Count = 536870912   System.Collections.Generic.List<bool>
-       base    {"Exception of type 'System.OutOfMemoryException' was thrown."} System.SystemException {System.OutOfMemoryException}
-       base    {"Exception of type 'System.OutOfMemoryException' was thrown."} System.Exception {System.OutOfMemoryException}
+       Data    {System.Collections.ListDictionaryInternal} System.Collections.IDictionary {System.Collections.ListDictionaryInternal}
        HelpLink    null    string
+       InnerException  null    System.Exception
        Message "Exception of type 'System.OutOfMemoryException' was thrown."   string
        Source  "mscorlib"  string
        StackTrace  "   at System.Collections.Generic.Mscorlib_CollectionDebugView`1.get_Items()"   string
+       TargetSite  {T[] get_Items()}   System.Reflection.MethodBase {System.Reflection.RuntimeMethodInfo}
+       Static members      
+       Non-Public members      
-       Raw View        
        Capacity    536870912   int
        Count   536870912   int
-       Static members      
+       Non-Public members      
-       Non-Public members      
+       _items  {bool[536870912]}   bool[]
        _size   536870912   int
        _syncRoot   null    object
        _version    536870912   int
        System.Collections.Generic.ICollection<T>.IsReadOnly    false   bool
        System.Collections.ICollection.IsSynchronized   false   bool
        System.Collections.ICollection.SyncRoot {object}    object
        System.Collections.IList.IsFixedSize    false   bool
        System.Collections.IList.IsReadOnly false   bool
        item    false   bool
-       Type variables      
        T   bool    bool

And here are the classes I am currently working on:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace OrganicCodeDesigner
{
    public class DynamicList64Tail<T> : iList64<T>
    {
        private List<T> data;

        public DynamicList64Tail()
        {
            data = new List<T>();
        }


        public void Add(T item)
        {
            data.Add(item);
        }       

        public void Clear()
        {
            data.Clear();
        }

        public bool Contains(T item)
        {
            return data.Contains(item);
        }

        public ulong? IndexOf(T item)
        {
            if(this.data.Contains(item)) {
                return (ulong)data.IndexOf(item);
            }
            return null;
        }

        public T this[ulong index]
        {
            get
            {
                return data[(int)(index)];
            }
            set
            {
                data[(int)(index)] = value;
            }
        }


        public ulong Count
        {
            get { return (ulong)data.Count; }
        }

    }
}


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections;

namespace OrganicCodeDesigner
{
    // @todo: Create IList64, with 64-bit longs in mind.
    // @todo: Create BigIntegerList, which may supersede this one.
    public class DynamicList64<T> : iList64<T>
    {
        private List<iList64<T>> data;

        private ulong count = 0;
        private ulong depth = 0;

        public DynamicList64()
        {
            data = new List<iList64<T>>() { new DynamicList64Tail<T>()};
            count = 0;
        }

        public DynamicList64(ulong depth)
        {
            this.depth = depth;
            if (depth == 0)
            {
                data = new List<iList64<T>>() { new DynamicList64Tail<T>() };
            }
            else
            {
                depth -= 1;
                data = new List<iList64<T>>() { new DynamicList64<T>(depth) };
            }
        }

        internal DynamicList64(List<iList64<T>> data, ulong depth)
        {

            this.data = data;
            this.depth = depth;
            this.count = Int32.MaxValue;


        }

        public void Add(T item)
        {
            if (data.Count >= Int32.MaxValue)
            {
                //@todo: Do switch operation, whereby this {depth, List l} becomes this {depth + 1, List.Add(List l), count = 1}, and the new object becomes {depth, List l, count = max}  
                DynamicList64<T> newDynamicList64 = new DynamicList64<T>(this.data, this.depth);
                this.data = new List<iList64<T>>() { newDynamicList64 };
                this.count = 0;
                this.depth += 1;
            }

            if(data[data.Count-1].Count >= Int32.MaxValue) {
                if (depth == 0)
                {
                    data.Add(new DynamicList64Tail<T>());
                }
                else
                {
                    data.Add(new DynamicList64<T>(depth - 1));
                }
            }

            data[data.Count - 1].Add(item);
            count++;
        }



        public void Clear()
        {
            data.Clear();
            data = new List<iList64<T>>() { new DynamicList64Tail<T>() };
            count = 0;
            depth = 0;
        }

        public bool Contains(T item)
        {
            foreach(iList64<T> l in data) {
                if(l.Contains(item)) {
                    return true;
                }
            }
            return false;
        }

        public ulong? IndexOf(T item)
        {
            for (int i = 0; i < data.Count; i++ )
            {
                if (data[i].Contains(item))
                {
                    return (ulong)(((ulong)i * (ulong)(Int32.MaxValue)) + data[i].IndexOf(item).Value);
                }
            }

            return null;           
        }

        public T this[ulong index]
        {
            get
            {
                return data[(int)(index / Int32.MaxValue)][index % Int32.MaxValue];
            }
            set
            {
                data[(int)(index / Int32.MaxValue)][index % Int32.MaxValue] = value;
            }
        }


        public ulong Count
        {
            get { return this.count; }
        }

    }
}


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace OrganicCodeDesigner
{
    public interface iList64<T>
    {
        void Add(T item);
        void Clear();
        bool Contains(T item);
        ulong? IndexOf(T item);
        T this[ulong index] { get; set;}
        ulong Count { get; }

    }
}

And the test program’s code:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using OrganicCodeDesigner;

namespace OrganicCodeDesignerListDictionaryTest
{
    public partial class MainForm : Form
    {
        public MainForm()
        {
            InitializeComponent();
        }

        private void Button_TestList_Click(object sender, EventArgs e)
        {
            DynamicList64<bool> newList = new DynamicList64<bool>();
            newList.Add(true);
            newList.Add(false);

            bool b = true;
            for (ulong i = 0; i < 68719476736; i++)
            {
                b = !b;
                newList.Add(b);
                //if(i%4096==0) {
                    //TextBox_Output.Text += "List now contains " + i + "\r";
                //}
            }

            TextBox_Output.Text += "Successfully added all the bits.\r";
        }

        private void Button_TestDictionary_Click(object sender, EventArgs e)
        {

        }
    }
}

Perhaps you can spot the error?

  • 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-12T18:34:38+00:00Added an answer on June 12, 2026 at 6:34 pm

    Perhaps you can spot the error?

    I think the error is here:

    I figured they’d suck up only ~1 bit each, so I’d get some good metrics / precision for testing my program.

    A bool takes one byte, not one bit – so you’ve drastically underestimated the size of your list. You’re actually running into an error with 512MB of bools. As Reed Copsey is editing a little faster than me – I suspect the list is trying to increase its size by allocating an array 2x it’s current size [i.e. a 1GB array] and that this is running into some .net limitations.

    This is probably a good time to start implementing your splitting logic.

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

Sidebar

Related Questions

Developing a project of mine I realize I have a need for some level
I made a sort of silly error in judgement when I first started developing
While developing a design using jQuery I stumbled across a problem. How would I
I am developing an ADO application (32 bit) on Windows 7 64 bit SP1
I'm developing a Windows 8 application using HTML5. The application requires some user data
I'm developing an application with J2ME Polish using a FramedForm. I'm trying to append
I am developing an application to use httpconnection to get some data to a
I am developing a magnifying glass and I was hoping I could get some
People! I'm developing a website where I have an Offers List (iframe). Inside this
Good evening. I am looking at developing some code that will collect EXIF data

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.