Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
GetObject vs NewObject vs CreateObject ?
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Programmation Orientée Object
Divers
Thread ID:
00502063
Message ID:
00502160
Vues:
28
>I have been using CreateObject() for I don't know how long now, but am thinking that I should be using GetObject() when I instance IE in forms so the same session would always be reused. Is that OK to do, or am I wasting memory/CPU cycles when I do that? Btw, am I the only one left here that is using CreateObject() instead of NewObject()?
>
>Thanks.

Steve,
There is nothing wrong with using CreateObject. If you are talking about VFP classes then there is a slight performance hit if you use NewObject. The ClassLib path is reassigned every time you use it and if you already know the ClassLib is in the path, you don't need it. When instantiating COM objects, I haven't noticed any appreciable difference using either one.

WRT, using GetObject, you have to do some extra error checking that you wouldn't normally need to do when using CreateObject(). You also need to make sure the user doesn't exit the instance of IE you have a reference to. Using CreateObject, you get your own copy of it and you can do with it what you want. If your machine is fast enough with enough memory (for caching), you won;t notice too much of an impact. FWIW, I ended going the CreateObject route using Excel because it was much more stable. Running on a dual PII 400 with 512MB RAM, I didn't have any performance issues.

Just my $0.02.
Larry Miller
MCSD
LWMiller3@verizon.net

Accumulate learning by study, understand what you learn by questioning. -- Mingjiao
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform