How to reorganize this FOR..NEXT loop to prevent the 'out of memory' warning?
- From: "OK" <oku@xxxxxxxxx>
- Date: Sun, 18 Nov 2007 12:28:32 +0100
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?
.
- Follow-Ups:
- Re: How to reorganize this FOR..NEXT loop to prevent the 'out of memory' warning?
- From: Richard Mueller [MVP]
- Re: How to reorganize this FOR..NEXT loop to prevent the 'out of memory' warning?
- Prev by Date: Re: Accessing DB through VB
- Next by Date: Re: IE browser: how to refresh it?
- Previous by thread: Re: How to change the color of an Image control border
- Next by thread: Re: How to reorganize this FOR..NEXT loop to prevent the 'out of memory' warning?
- Index(es):
Relevant Pages
|