[Overview][Constants][Types][Classes][Procedures and functions][Variables] | Reference for unit 'Classes' (#fcl)

# TMemoryStream.Realloc

Sets the new capacity for the memory stream

## Declaration

`protected function TMemoryStream.Realloc(`
`var NewCapacity: LongInt`
`):Pointer; virtual;`

## Description

SetCapacity sets the capacity of the memory stream, i.e. does the actual allocation or de-allocation of memory for the stream. It allocates at least NewCapacity bytes on the heap, moves the current contents of the stream to this location (as much as fits in) and returns the new memory location. Extra allocated memory is not initialized, i.e. may contain garbage.

Memory is allocated in blocks of 4 Kb; this can be changed by overriding the method.

## See also

TMemoryStream.Capacity |  | Current capacity of the stream.