View Single Post
  #3 (permalink)  
Old 01-07-2009, 11:14 AM
cjard's Avatar
cjard cjard is offline
VB.NET Forum All-Mighty
.NET Framework: .NET 2.0 (VS 2005)
 
Join Date: Apr 2006
Age: 65
Posts: 6,442
Reputation: 807
cjard has a reputation beyond reputecjard has a reputation beyond reputecjard has a reputation beyond reputecjard has a reputation beyond reputecjard has a reputation beyond reputecjard has a reputation beyond reputecjard has a reputation beyond reputecjard has a reputation beyond reputecjard has a reputation beyond reputecjard has a reputation beyond reputecjard has a reputation beyond repute
Default

Quote:
Originally Posted by mad_schatz View Post
Unfortunately this reading process takes long time. About 4 mins.
Eek!

ReDim Preserve laCoords(liArrayLen) would be your problem



Every time you read one number, you re-dimension the array to make it one larger. Problem is, to re-dim an array VB must create a new array and copy all the elements to the new one. Given that you re-dim it 300,000 plus times, and the average array size is 150,000 elements, that means 45 billion copy operations of 4 bytes of data (which may be stored in an 8 byte memory location) and youre talkling about shifting around somewhere between 180 and 360 gigabytes of information, just to read a 150kb file!

Stop using array, and stop using Redim Preserve. Use a data storage container that supports your method of reading, and also what you plan to do with the data afterwards. At the very least, work out from the file size, how many singles it is likely to contain and pre-dim an array of the appropriate size
__________________
DW1 DW2 DW3 DW4 DNU PQ
Reply With Quote