How to reorganize this FOR..NEXT loop to prevent the 'out of memory' warning?



I am faced with a strange memory problem by which my source fires an Out of
memory problem.
I have investigated the whole subroutine and it shows that a FOR NEXT loop
consumes too much memory which isn't released by VB after the loop.

Sub ProblemRoutine
Dim var7 as string
Dim var8 as string
Dim rij as long


DO


For rij = 1 To testgrid.Rows - 1
var7 = testgrid.Cell(flexcpText, rij, 7)
var8 = testgrid.Cell(flexcpText, rij, 8)

If IsNumeric(var7) And IsNumeric(var8) Then
If CLng(var8) = ID_emp And CLng(var7) = Weeknr
Then
Found = True
Exit For
End If
End If
Next rij


'some processing in which more records are added to the
testgrid, each row only consumes about 4 Byte

LOOP until ...

END Sub

In case that more than 2000 rows are added to the testgrid, the memory
consumption is about 200 Bytes for one FOR-NEXT loop only. How should I
change my FOR NEXT loop in order to free the memory consumption?




.



Relevant Pages

  • Re: memory leak after calling a fortran function
    ... After calling the same function in a loop 10 times I got the same ... memory problem. ... Debug build memory usage details ... 2816k before fortran function call ...
    (comp.lang.fortran)
  • 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)
  • Re: Restoring a NorthStar Horizon, problems with SRAM board
    ... A-D FDC is a memory mapped IO device so I would expect some behavior ... loop read/write functions - which puts the system into a two instruction ... SRAM on the Vector Graphics Flashwriter video card located at $F000 ...
    (comp.sys.northstar)