System.TObject.NewInstance

From RAD Studio VCL Reference
Jump to: navigation, search

Contents

Delphi Information

From System.pas

	class function NewInstance(): TObject; virtual;


Unit: System

Type: method

Visibility: public

Member Of: TObject

C++ Information

From System.hpp

	virtual __classmethod System::TObject * __fastcall NewInstance(void);


Unit: System

Type: method

Visibility: protected

Member Of: TObject

Description

Allocates memory for an instance of an object type and returns a pointer to that new instance.


All constructors call NewInstance automatically. NewInstance calls InstanceSize to determine how much memory containing a particular instance to allocate from the heap. Do not call NewInstance directly.

Override NewInstance only for special memory allocation requirements. For example, when allocating a large number of identical objects that all need to be in memory at the same time, you can allocate a single block of memory for the entire group, then override NewInstance to use part of that larger block for each instance.

If you override NewInstance to allocate memory, you may need to override FreeInstance to deallocate the memory.

Note:  By default, NewInstance calls InitInstance.

See Also

Personal tools
Translations
Newest Version