Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Memory Pre-Allocation Trick?
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
COM/DCOM et OLE Automation
Divers
Thread ID:
00721182
Message ID:
00721393
Vues:
24
Steve,

I don't think it's going to help much, because the effort you have to go through in VFP code to actually use the preallocated string space isn't worth it.

VFP is as fast as the underlying C++ code when it is doing string concatenations of the form:

lcX = lcX + ...

There's probably other VFP code that could be optimized in the class that would have a bigger improvement than spending time worrying about 8k worth of memory allocations.

>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.
df (was a 10 time MVP)

df FoxPro website
FoxPro Wiki site online, editable knowledgebase
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform