Way to free memory as I input lines from a file?

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance

From: Steven Douglas (theboydouglas_at_hotmail.com)
Date: 09/02/04


Date: Thu, 2 Sep 2004 02:36:50 -0700

Hi,

I have some code where I open a very large file into
memory then enter a loop where I input each line one by
one, analyse it & draw data from it depending on certain
criteria.

The file being opened is 216,000 lines long and when the
code is running it just seems to get slower and slower
the further down the file it gets.

My question is, can I speed it up? I'm no expert, but
what I presume is happening is that Excel is, line by
line, opening more and more of the file into memory and
keeping it there. If that's the case, is there a way of
releasing the memory (of the lines) i no longer need?

I don't totally understand what the Filehandle & Freefile
things are, I just know that they work. In fact, would it
be quicker to use (Open openfile For Binary Access Read
As #Filehandle) & return data from the file that way?
(it's all the same place).

Any help on this would be greatly appreciated!

Thanks for your time,

Steven Douglas

Below is a very cut down version of the loop I'm running,
there are lot of other IF's & Do__Loop statements in
there, and I have them running as efficiently as possible.

'------------------------------------------------------

openfile = strDir & strBureau & "\XND.CSV"
Filehandle = FreeFile()

Open openfile For Input As #Filehandle

Do
Line Input #Filehandle, strData

 If Mid(strData, 2, 1) = "A" Then
  varkWh(1) = Mid(strData, 71, 8)
  varkWh(2) = Mid(strData, 55, 13)
  varkWh(3) = Mid(strData, 82, 30)
 End If

'CAN i PUT A LINE HERE TO RELEASE MEMORY

Loop Until EOF(1)
'------------------------------------------------------



Relevant Pages

  • Way to free memory as I input lines from a file?
    ... >memory then enter a loop where I input each line one by ... >I don't totally understand what the Filehandle & Freefile ... >be quicker to use (Open openfile For Binary Access Read ... >Below is a very cut down version of the loop I'm running, ...
    (microsoft.public.excel.programming)
  • Re: Innovative Systems FPE...
    ... window so one could loop using one register for copy in/out but I ... suppose you can simply unroll the loop. ... I mean't swap the order of the bytes in the hardware ... would be a graphical memory map, but even then, I usually rotate it ...
    (comp.sys.apple2)
  • Re: Fast string operations
    ... > is why people use unsafe code now and then to use pointer arithmetic to ... > loop over arrays without all the unnecessary bounds checking. ... don't return the trimmed string". ... The customer perceives this as a memory leak. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Performance Improvement of complex data structure (hash of hashes of hashes)
    ... Anno Siegel wrote: ... >> Here is the code that I'm using to build up this data structure. ... loop through and increment the ... I know that memory allocation in C is expensive, ...
    (comp.lang.perl.misc)
  • Re: Cost of calling a standard library function
    ... It accesses/reads memory using esi 4 ... > safly move it within the cache, without having to go via ebx. ... try it the same thing on a different earlier CPU, ... should check it out...for "tight inner loop" stuff, ...
    (alt.lang.asm)