Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Trying to track down memory leak(s)
Message
De
25/09/2011 07:42:58
 
 
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:
01524639
Vues:
111
J'aime (1)
>We see that write_log function time grew, Parse function time grew and even GetServerVersion time grew although this function code is very simple
>
>procedure GetServerVersion() as string;
>      helpstring "Version # gleaned from .DLL  Returns This.cServerVersion"
>
>   this.write_log('Entering method...', program(), '1')
>   this.write_log('Returning: '+ '0-'+this.cServerVersion, program(), '2')
>
>   return this.RetValToSTR('0-' + this.cServerVersion)
>   endproc
>
>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.
>
>I look up this procedure and it stores every message in the property, so this property is going to grow more and more and therefore the execution time is going to slow down.
>
>I'm not sure what can I do to not let it grow that much. Although I found one potential thing to make it run quicker and implemented it.






>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


Don't forget that for every append, it has to open the file, seek to the end and close the file

>I look up this procedure and it stores every message in the property, so this property is going to grow more and more and therefore the execution time is going to slow down.

Adding something to a string property ( aka this.something = m.this.something + '12233') really slows down when the string gets longer.
This originally crossed my mind - but I dropped it since it did not fit in a memory leak scenario

Also, if you log, why keep the log in memory ?

For large string properties, where you just append data - I prefer to use 'ADODB.Stream' http://msdn.microsoft.com/en-us/library/ms675032(v=VS.85).aspx
I have suggested this for ( http://www.vfpwinsock.com/vfpwinsock.asp ) vfpwinsock - a class that sends an email. It builds up the message like this: this.data = this.data + ...
When the message gets big - ie with large attachments - it really is getting slow



Logging is an overhead - so the time of logging must be as small as possible



Exit memory leak ...



For a quick test: put return as the first statement in the write_log() function
Gregory
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform