Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
How does VFP load class methods into memory?
Message
De
16/11/2009 09:08:05
 
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Versions des environnements
Visual FoxPro:
VFP 9 SP1
Divers
Thread ID:
01434853
Message ID:
01434919
Vues:
71
>>>Hi,
>>>
>>>I am thinking if it is better to break a class into two classes and have one inherit from another. Mainly I am considering this to see if I can speed up loading the objects using the class. I have not quantified the speed of loading the objects, this is just a guess that the speed can be improved. Some forms can have up to about 20 objects using this class (as base or are instantiated in the INIT method).
>>>
>>>The class has 16 methods. Only 8 of them are used in one part of the program. All 16 are used only in some other parts of the application. My question is, does VFP 9, when instantiating the class, loads the code from all 16 methods into memory? Or it only loads the method when the method is used?
>>>
>>>TIA.
>>
>>I wonder whether the number of methods (8 or 16 here) is going to influence the speed of instantiating the objects. The code is the same for any one class. So, I'd say that the methods are loaded only once and shared amongst the objects of the same class. The 'load more code' penalty, if any, only happens once imo
>
>Hi Gregory,
>
>I am not sure I understand/agree with you. Say, the class we are discussing has a method "MyMethod1". If a form uses 20 objects based on this class, the method "MyMethod1" is loaded 20 times, not one time, when the form is instantiated. Right?


I think 'MyMethod1' is only loaded once - it's readonly code anyway

I just did a test - based on http://fox.wikis.com/wc.dll?Wiki~TestMemoryCreateDestroy~VFP : function LogFunc(tcClass)
10000 create/destroy 

Class          memory
MyClass     6236860
MyClass2   6290496

(6290496-6236860)/10000 = 5.36 bytes
The compiled code of MyClass2 is about 128 k
define class MyClass as relation


enddefine
define class MyClass2 as relation

&& lots of functions
enddefine
Gregory
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform