hi,
 
i do load 1.000.000 line ( = 82Kb)  into a String, no Problem.
than i try SUBSTR() on that String, no Problem
 
when i try to AADD(aBig,cResult) my RAM increase until crash ...
 
v1.9.355, XP Sp3, 2GB no "SwapDisk"
 
greetings by OHR
Jimmy
 
*** Code ***
#include "Fileio.ch"
 
#define CRLF   CHR(13)+CHR(10)
#define MAKEERROR
 
PROCEDURE Main
LOCAL cFile    := "BIGTEXT.TXT"
LOCAL cBuffer  := ""
LOCAL aBig     := {}
LOCAL nStart
LOCAL nStop
 
IF FILE( cFile )
ELSE
?  TIME()
?  "creating File"
   nStart   := SECONDS()
?  CreFile( cFile )                      // 82.000.000
?  nStop    := SECONDS()-nStart          // Sec.
   WAIT
ENDIF
 
?  TIME()
?  "reading  File"
   nStart   := SECONDS()
   cBuffer  := ReadFile( cFile )
?  nStop    := SECONDS()-nStart          // Sec
?  LEN(cBuffer)                          //
   WAIT
 
?  TIME()
?  "SUBSTR   File"
   nStart   := SECONDS()
   aBig     := Zerlege(cBuffer)
?  nStop    := SECONDS()-nStart          // 0.06 Sec
?  LEN(aBig)                             // *78
   WAIT
 
RETURN
 
FUNCTION Zerlege(cBuffer)
LOCAL aBig  := {}
LOCAL cText
LOCAL nStart
LOCAL nStop
 
?  iMax := LEN(cBuffer)
   nStart := 1
 
   DO WHILE .T.
      nStop  := AT(CRLF,cBuffer,nStart)
      IF nStop > 0
         cText := SUBSTR(cBuffer,nStart,nStop)
         nStart := nStop+2
   //   
   // this will increase RAM until crash
   //
#IFDEF MAKEERROR
         AADD(aBig ,cText )
#ENDIF
   //
   // output is slow .. we know
   //
#IFDEF MAKESLOW
?        nStart
#ENDIF
   //
   // but this is 100x times slower until BUG apprear
   //
#IFDEF MAKESLOW
?        cText
#ENDIF
      ELSE
         EXIT
      ENDIF
   ENDDO
 
RETURN aBig
 
FUNCTION CreFile( cFile )
LOCAL nSource, cBuffer
LOCAL nBytesSum      := 0
LOCAL cLine
LOCAL i
 
   IF ( nSource := FCreate( cFile, FC_NORMAL ) ) == -1
      FClose( nSource )
      ? "Datei kann nicht erstellt werden:", cFile
      RETURN FError()
   ENDIF
 
   cLine := Replicate("A", 78 )+CRLF
   FOR i = 1 TO 1000000
      nBytesSum += FWrite( nSource, cLine )
   NEXT
 
   FClose( nSource )
 
RETURN nBytesSum
 
FUNCTION ReadFile( cFile )
LOCAL nSource, cBuffer
LOCAL nLaenge     := 0
 
   nSource := FOpen( cFile, FO_READ )
   IF FError() <> 0
      ? "Datei kann nicht geöffnet werden:",cFile
      RETURN ""
   ENDIF
 
   FSEEK (nSource,0,FS_SET)                        && be sure on Start
?  nLaenge := FSEEK (nSource,0,FS_END)      && Ende suchen
   FSEEK (nSource,0,FS_SET)                        && back to Start
 
   cBuffer := Space( nLaenge )                   // make big buffer
   FRead( nSource, @cBuffer, nLaenge )    // read hole file
 
   FClose( nSource )
 
RETURN cBuffer                                      // 82kb String
*** Eof ***