Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Trying to track down memory leak(s)
Message
 
 
To
25/09/2011 11:12:18
General information
Forum:
Visual FoxPro
Category:
Troubleshooting
Environment versions
Visual FoxPro:
VFP 9 SP2
Miscellaneous
Thread ID:
01398453
Message ID:
01524655
Views:
82
>>>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

It's all a bit more involved. First, do you want to open the file with 12 (exclusive)? If so, I would not be able to analyze it, etc.?

And it will require more changes - so becomes more complex to do a re-write.
If it's not broken, fix it until it is.


My Blog
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform