Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Trying to track down memory leak(s)
Message
De
25/09/2011 11:12:18
 
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Problèmes
Versions des environnements
Visual FoxPro:
VFP 9 SP2
Divers
Thread ID:
01398453
Message ID:
01524650
Vues:
88
>>Yes, - but another important point is appending each time to this.cInvokeFullLog. As it gets bigger it will slow down more
>>
>>3 possibilities in order of speed
>>
>>(1) get rid of cInvokeFullLog
>>
>>(2) write it to another file with fcreate() and fputs()
>>
>>(3) use an ADO stream
>
>Yes, I agree that cInvokeFullLog may not be needed at all - why not simply check the fsize every time?
>
>BTW, unless I did something wrong my tests are opposite:
>
>LOCAL i, gnErrFile, pnSize, lnSeconds
>lnSeconds = SECONDS()
>FOR i=1 TO 1000
>  STRTOFILE( 'Error information to be written here' + CHR(13) + CHR(10),'errors1.txt', .t.)
>NEXT
>=MESSAGEBOX(SECONDS() - m.lnSeconds)
>
>lnSeconds = SECONDS()
>FOR i=1 TO 1000
>
>IF FILE('errors.txt')  && Does file exist? 
>   gnErrFile = FOPEN('errors.txt',12)     && If so, open read/write
>   pnSize = FSEEK(gnErrFile,0,2) 
>ELSE
>   gnErrFile = FCREATE('errors.txt')  && If not create it
>ENDIF
>IF gnErrFile < 0     && Check for error opening file
>   WAIT 'Cannot open or create output file' WINDOW NOWAIT
>ELSE  && If no error, write to file
>   =FWRITE(gnErrFile , 'Error information to be written here')
>ENDIF
>=FCLOSE(gnErrFile )     && Close file
>NEXT
>=MESSAGEBOX(SECONDS() - m.lnSeconds)
>
>
>Second loop takes longer.



It goes without saying that you fcreate() the log file in the init() of the class and store the FD as a class property

Then, fopen() and fseek() are not necessary any more
Gregory
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform