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

  • Home
  • SEARCH
  • 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 3218102
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T15:29:19+00:00 2026-05-17T15:29:19+00:00

I have a very large graph stored in a single dimensional array (about 1.1

  • 0

I have a very large graph stored in a single dimensional array (about 1.1 GB) which I am able to store in memory on my machine which is running Windows XP with 2GB of ram and 2GB of virtual memory. I am able to generate the entire data set in memory, however when I try to serialize it to disk using the BinaryFormatter, the file size gets to about 50MB and then gives me an out of memory exception. The code I am using to write this is the same I use amongst all of my smaller problems:

StateInformation[] diskReady = GenerateStateGraph();
BinaryFormatter bf = new BinaryFormatter();
using (Stream file = File.OpenWrite(@"C:\temp\states.dat"))
{
    bf.Serialize(file, diskReady);
}

The search algorithm is very lightweight, and I am able to perform searches on this graph with no problems once it is in memory.

I really have 3 questions:

  1. Is there a more reliable way to
    write a large data set to disk. I
    guess you can define large as when
    the size of the data set approaches
    the amount of available memory,
    though I am not sure how accurate
    that is.

  2. Should I move to a more database
    centric approach?

  3. Can anyone point me to some
    literature on reading portions of a
    large data set from a disk file in
    C#?

  • 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-17T15:29:20+00:00Added an answer on May 17, 2026 at 3:29 pm

    Write entries to file yourself. One simple solution would be like:

    StateInformation[] diskReady = GenerateStateGraph();
    BinaryFormatter bf = new BinaryFormatter();
    using (Stream file = File.OpenWrite(@"C:\temp\states.dat"))
    {
      foreach(StateInformation si in diskReady)
        using(MemoryStream ms = new MemoryStream())
        {
          bf.Serialize(ms, diskReady);
          byte[] ser = ms.ToArray();
          int len = ser.Length;
          file.WriteByte((byte) len & 0x000000FF);
          file.WriteByte((byte) (len & 0x0000FF00) >> 8);
          file.WriteByte((byte) (len & 0x00FF0000) >> 16);
          file.WriteByte((byte) (len & 0x7F000000) >> 24);
          file.Write(ser, 0, len);
        }
    }
    

    No more than the memory for a single StateInformation object’s memory is needed at a time, and to deserialise you read four bytes, construct the length, create a buffer of that size, fill it, and deserialise.

    All of the above could be seriously optimised for speed, memory use and disk-size if you create a more specialised format, but the above goes to show the principle.

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

Sidebar

Related Questions

I have a very large XML file which has like 40000 data, and when
I have a very large program which I have been compiling under visual studio
I have a very, very large graph, and I want to find the shortest
I have a very large, dense, labeled graph that I have visualized with GraphPlot.
I have a very large Excel sheet converted from a 6000 page PDF file,
I have a very large UIView approx 3000x3000 in size. In this large view
I have a very large table of over 9 million rows and in my
I have a very large ASP.NET application in C#. The issue is simple yet
I have a very large data file with around 60000 rows. I need to
I have a very large possible data set that I am trying to visualize

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.