Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Trying to track down memory leak(s)
Message
 
 
À
25/09/2011 11:07:14
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:
01524649
Vues:
93
>>>>Although we see it calls the growing time write_log function first, so that may be the main reason. I can comment out this function and re-test, but I think I identified the main culprit for slowness is write_log function.
>>>
>>>If you are using strtofile( with append - that is very slow
>>>Just ran a test - 40000 times
>>>strtofile( , append) = 12 secs
>>>fwrite()/fputs() = 0.016 secs
>>>
>>>
>>
>>With fwrite - should not you first go to the end of the file? Are you saying it's better?
>>Can you post the test?
>>
>>The changes I've made so far already done it - although I suspect I can do better. Yes, write_log uses strtofile to append.
>>
>>I found the following:
>>
>>In each call it first created a string it was supposed to write, added this string to property, and only then check if the verbosity level greater than needed - if so, it bailed out. I moved that code right at the top.
>>
>>Few local variables were not declared as local - I added them to local declaration.
>>
>>For CRLF and TAB the variables were used - I switched to defined constants.
>>
>>So, these were the only changes I've done and yet the results are much better now and the time does not increase. I think the main thing is I moved the bail out case to the very top and I've been testing with the low verbosity level.
>>
>>This is the current code
>>
>>
>> strtofile(m.tcMessage + CRLF, .cProgramDataPath + iif(m.tlLongCall, .cLongCallLogFile, .cLogFile), .t.)
>>         if (not m.tlLongCall) and m.tcMessageType = 'E'
>>            * Now always make an entry into the LongCall Log when messagetype = "E"
>>            strtofile(m.tcMessage + CRLF, .cProgramDataPath + .cLongCallLogFile, .t.)
>>            if .nVerbosityLevel < 5
>>               strtofile(CRLF + 'Here is a log at full verbosity that led up to this error...' + CRLF + CRLF, .cProgramDataPath + .cLogFile, .t.)
>>               strtofile(.cInvokeFullLog + CRLF, .cProgramDataPath + .cLogFile, .t.)
>>               strtofile(replicate('-', 80) + CRLF + CRLF, .cProgramDataPath + .cLogFile, .t.)
>>            endif
>>         endif
>>
>>What do you think we want to switch to?
>
>Naomi,
>
>you Strtofile() three times to the same file. I suggest that you add to the string instead, and do the strtofile() only once.
>
I don't think it will buy me anything, besides, it only happens in the error case - not in the regular case.
If it's not broken, fix it until it is.


My Blog
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform