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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T00:54:05+00:00 2026-05-13T00:54:05+00:00

I really REALLY hope that someone could help me. I have to pass almost

  • 0

I really REALLY hope that someone could help me.

I have to pass almost 400.000 records from a database to a textfile
Because of this amount the extension of the textfile is just something
I made up …(.you_name_it)
I get an error while writing the data to the file at +/- 9000 records.
The error = Exception of type ‘System.OutOfMemoryException’ was thrown
And I don’t know the solution 🙁

This is the peace of code I use for writing the records to the file.

        this.path_to_file =
        ConfigurationManager.AppSettings["ExportDir"] +
DateTime.Now.ToString(ConfigurationManager.AppSettings
["Export_FileName"]) + ConfigurationManager.AppSettings
["Export_Extension"];


        FileStream fm = new FileStream
           (this.path_to_file, FileMode.Create, FileAccess.ReadWrite,
FileShare.ReadWrite);

        StreamWriter sw = new StreamWriter(fm, Encoding.Default);

        List<Export> exportRecords = null;

        exportRecords = ExportList();
        try
        {
            int i = 0;
           foreach (Export ex in exportRecords)
           {
               sw.Write(ex.ExportLine());
              sw.Write(sw.NewLine);
              sw.Flush();
              exportlines += ex.ExportLine() + "\n";
               i++;
           }
        }
        catch (Exception exc)
        {
           Log.Write(exc.Message);
        }
  • 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-13T00:54:05+00:00Added an answer on May 13, 2026 at 12:54 am

    Why is this line in your code?

          exportlines += ex.ExportLine() + "\n"
    

    Assuming it is a string variable it grows and grows and grows… and consumes memory.

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

Sidebar

Related Questions

I really hope someone can help on this because I'm learning cocoa and have
This really, really urks me, so I hope that someone can give me a
Really hope someone can point me in the right direction as I have no
My question really has three related parts which I hope you can help me
I'm writing this in the forlorn hope that someone has already done something similar.
I'm almost 100% sure I have ready every post on the internet that contains
Really simple question - how do I do a search to find all records
Really my question has more to do with the server-side scrubbing of html that's
I really feel that I should learn Lisp and there are plenty of good
I really enjoyed Jeff's post on Spartan Programming . I agree that code like

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.