TObject.newinstance
Allocate memory on the heap for a new instance
Declaration
Source position: objpash.inc line 211
public
class function newinstance : TObject; Virtual;
Description
NewInstance allocates memory on the heap for a new instance of the current class. If the memory was allocated, the class will be initialized by a call to InitInstance . The function returns the newly initialized instance.
This method can be overridden to implement e.g. object pooling. Note that the method is responsible for correctly initializing the object, i.e. zeroing out the new instance.
Errors
If not enough memory is available, a Nil pointer may be returned, or an exception may be raised.
See also
Name | Description |
---|---|
Create | TObject Constructor |
FreeInstance | Clean up instance and free the memory reserved for the instance. |
InitInstance | Initialize a new class instance. |
InstanceSize | Return the size of an instance. |