Win a copy of Design for the Mind this week in the Design forum!
    Bookmark Topic Watch Topic
  • New Topic

Alternatives to arrays

 
Sam Bluesman
Ranch Hand
Posts: 191
  • Mark post as helpful
  • send pies
  • Report post to moderator
Hi.

I have a program which needs to store data from text files (comprising of several Mb). I am storing this data into a number of arrays.

To do so, I am currently reading these files once to get the number of lines so that I can get the array length that will be required.

I am then reading the file again and storing this data as the file reader read line by line.

Is there is anything else other than arrays I can use which would mean I dont have to read the file twice? In addition, creating these large arrays are giving me the OutOfMemory heap problem.

Thanks
 
fred rosenberger
lowercase baba
Bartender
Pie
Posts: 12097
30
Chrome Java Linux
  • Mark post as helpful
  • send pies
  • Report post to moderator
well, if you're storing the whole thing in memory, i'm not sure changing the storage object will help much with the outofmemory error.

do you need to store the whole thing in memory? I would think that what you are doing with the data should determine what you use to store it...
 
Sam Bluesman
Ranch Hand
Posts: 191
  • Mark post as helpful
  • send pies
  • Report post to moderator
Well basically Im ending up with a 2d array with dimensions over 20000 by 20000. The idea this is then put into a text file as a grid
 
Jim Yingst
Wanderer
Sheriff
Posts: 18671
  • Mark post as helpful
  • send pies
  • Report post to moderator
Okay, let's not waste people's time by having the same conversation twice. The other thread seems to have more info, so I'll close this one. Followups can go here please.
 
    Bookmark Topic Watch Topic
  • New Topic