RAD Studio VCL Reference
TInterfacedObject::NewInstance Method

Allocates memory for each instance of an interfaced object.

class function NewInstance: TObject; override;
TObject NewInstance();

All constructors call System::TInterfacedObject::NewInstance automatically. System::TInterfacedObject::NewInstance calls System::TObject::InstanceSize to determine how much memory to allocate from the heap to contain a particular instance. Do not call System::TInterfacedObject::NewInstance directly. 

System::TInterfacedObject overrides System::TInterfacedObject::NewInstance to increment the reference count when a new instance is created. This prevents any constructor from accidentally deleting the instance due to a System::TInterfacedObject::RefCount of zero. The System::TInterfacedObject::AfterConstruction method decrements the value of System::TInterfacedObject::RefCount after all constructors have executed. 


Copyright(C) 2009 Embarcadero Technologies, Inc. All Rights Reserved.
What do you think about this topic? Send feedback!