1.

How Is The Memory Used Within An Object In Delphi?

Answer»
  • Classes are built to create objects and then the objects are allocated in the constructors and used in the METHODS
  • The objects that are allocated in the CONSTRUCTOR should have a releasing point and that is also in the destructor method. 
  • The process in which, the constructor constructs, and after the WORK destructor destructs is called CONVERSE process. 
  • The classes can be made to handle the memory properly by using the persistence property after the object that is currently used is being destroyed. 

The example is as follows:

unit My;
interface
uses
Classes;
type
TMy = class
private
fileData : TStringList;
published
Constructor Create(CONST fileName : string);
Destructor Destroy; override;
procedure PrintFile;
end;

The example is as follows:

unit My;
interface
uses
Classes;
type
TMy = class
private
fileData : TStringList;
published
Constructor Create(const fileName : string);
Destructor Destroy; override;
procedure PrintFile;
end;



Discussion

No Comment Found