Re: Unrecoverable error 332 string/array memory overflow



Mel

When you AADD() to an array the existing array is copied with the extra amount
of memory added for the new element, so doing that involves a lot of memory
being moved around.

If you allocate enough elements to your arrays beforehand then you should not
see the problem.
Eg
aLines := ARRAY( 2400 )
i := 1
aLine := (csvarray(cLine) )
aLines[ i ] := aLine
IF i = 2400
// Write the array to DBF
UpdateDBF( aLines )
aFill( aLines, '' )
i := 1
ENDIF

Putting something like
@ 0,0 SAY ''
inside your loop will give the GC a chance to kick in to clean up memory.

You could also change to structure of the code to only require a single array.
Eg
aLine := (csvarray(cLine) )
// Write the array to DBF
UpdateDBF( aLine )

Another way is to allocate a buffer that you append your data to and write it
when the buffers full, this is done by opening the DBF as a file
(FOpen()/FWrite()/FClose()) not as a database (USE).

Take a look at CLICK! source on the OASIS to see some fast routines for doing
this.

HTH
Steve


.



Relevant Pages

  • Re: Readall command
    ... > How do I read a text file into an array except the first five lines? ... You could use the 'skipline' method to move down 5 lines and then use the ... Dim oFSO, oInputFile, aLines, i ...
    (microsoft.public.scripting.vbscript)
  • Re: Memo Fields
    ... next to Gerben and Lees suggestions, maybe you are looking for ALines. ... copies each line in a memo into an array. ... I've used memo fields in tables, ...
    (microsoft.public.fox.programmer.exchange)
  • Re: Fast string operations
    ... Looping: I thought looping over arrays in managed code was "slow" ... array handling and such. ... The problem with TrimHelper is that it always returns a new string instance. ... The customer perceives this as a memory leak. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: High Memory Consumption of Classes and Arrays
    ... Only the array itself has overhead. ... memory as a reference type. ... > least consume 40 bytes of memory. ...
    (microsoft.public.dotnet.framework.performance)
  • Re: Fast linked list
    ... > amounts of memory rather than huge chunks of it. ... random insertions into a vector/dynamic array are not as slow ... to cause a cache miss. ... some hard numbers on speed differences between lists and arrays. ...
    (microsoft.public.vc.mfc)

Loading