Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Memory Pre-Allocation Trick?
Message
De
11/11/2002 17:49:01
 
Information générale
Forum:
Visual FoxPro
Catégorie:
COM/DCOM et OLE Automation
Divers
Thread ID:
00721182
Message ID:
00721326
Vues:
23
>I have a VFP7 class with an empty string property. After instantiation, from 3 to 9 methods get called, and each concatenates 100-500 bytes in rapid succession, resulting in about a 5k stirng property when it's done. The caller consumes this string property before destroying the object.
>
>Would it make sense to pre-allocate memory for the object by setting the string property to Space(8192), and on the first write set the property to the first string and then concatenate after that?
>
>I am thinking that the object would run "faster" because the OS (or runtime) would not have to grow the stack space for the object as it runs. This is for a web app where I have potentially 60-70 objects going at any given second.

You could run some tests and let us know ;-)

Seriously, the only thing I can see that might be an issue would be the following:
MyProp = SPACE(8192) && Length is 8192
MyProp = < 100 Length String > && Length is now 100, VFP may garbage-collect the other 8092 bytes
Regards. Al

"Violence is the last refuge of the incompetent." -- Isaac Asimov
"Never let your sense of morals prevent you from doing what is right." -- Isaac Asimov

Neither a despot, nor a doormat, be

Every app wants to be a database app when it grows up
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform