Skip to content

TMemoryStream

Standard implementation of a stream that stores its data in memory.

Declaration

Source position: classesh.inc line 1630

type

  TMemoryStream = class(TCustomMemoryStream)
  public
    destructor Destroy;
    procedure Clear;
    procedure LoadFromStream;
    procedure LoadFromFile;
    function Write : LongInt;
  end;

Description

TMemoryStream is a TStream descendant that stores it's data in memory. It descends directly from TCustomMemoryStream and implements the necessary to allocate and de-allocate memory directly from the heap. It implements the Write method which is missing in TCustomMemoryStream.

TMemoryStream also introduces methods to load the contents of another stream or a file into the memory stream.

It is not necessary to do any memory management manually, as the stream will allocate or de-allocate memory as needed. When the stream is freed, all allocated memory will be freed as well.

Methods

Member Visibility Description
Clear public Zeroes the position, capacity and size of the stream.
Destroy public Frees any allocated memory and destroys the memory stream.
LoadFromFile public Loads the contents of a file into memory.
LoadFromStream public Loads the contents of a stream into memory.
Write public Writes data to the stream's memory.
See all Methods

See also

Name Description
TCustomMemoryStream Abstract stream that stores its data in memory.
TStream Base class for streams.