Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Alternatives to arrays

 
Ranch Hand
Posts: 191
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
lowercase baba
Posts: 13091
67
Chrome Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Wanderer
Posts: 18671
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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