Jump to content

Why does this run out of memory?

- - - - -

  • Please log in to reply
2 replies to this topic

#1
williamevanl

williamevanl

    Learning Programmer

  • Members
  • PipPipPip
  • 61 posts
 try

            {              

                using (StreamReader readFile = new StreamReader(path))

                {

                    string line;

                    string[] row;


                    while ((line = readFile.ReadLine()) != null)

                    {

                        row = line.Split('\t');

                       foreach (string[] blah in thisstring)

                        {


                            if (blah[0] == row[0])

                            {

                                 parsedData.Add(line);

                            }


                        }


                        count++;



                    }


                }

            }

and how can I keep this from happening, the text file it reads is about 200 megs. I've also tried to just split this file with a file splitter and four have failed me so far. :(

#2
dargueta

dargueta

    Writes binary right handed and hex left handed

  • Moderators
  • 4,720 posts
  • Programming Language:C, Java, C++, PHP, Python, Perl, Assembly, Bash, Others
  • Learning:JavaScript
You probably have a memory leak somewhere in your code. How big are the file chunks?
sudo rm -rf /

#3
williamevanl

williamevanl

    Learning Programmer

  • Members
  • PipPipPip
  • 61 posts
well each chunk is just a line right so not very long < 50.

Edit:
I just realized it gives up at 137549 rows which is exactly the same as the number that excel can show.

Edit:
well it looks like 90% of the file I was trying to read is blank spaces so I think thats what the problem was.

Edited by dargueta, 14 January 2011 - 01:30 PM.





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users