*Buffer = ReAllocateMemory(*Buffer, Size [, Flags])
Resizes the given memory buffer to a new size. The memory may be copied to a new location in the process if there is not enough memory available at its current location.


*Buffer The address of the memory area to resize. This value must be the result of a call to AllocateMemory() or ReAllocateMemory().

If this parameter is #Null, the command acts like AllocateMemory() and allocates a new memory area of the given size.
Size The size in bytes for the resized or allocated buffer.
Flags (optional) It can be one of the following values:
  #PB_Memory_NoClear: don't fill the extended memory area with zeros. It can help to have faster allocation if the
                      extended memory is used immediately. If the memory size is reduced, this flag has no effect.

Return value

Returns the new address of the memory area if it could be resized. In this case, the old '*Buffer' address can no longer be used. If resizing the memory area failed (because there is not enough memory available), the result is zero, and the '*Buffer' address is still valid with the existing memory area and the old size.


If the size of the memory area is increased, any new bytes are initially filled with zeros unless the #PB_Memory_NoClear flag is specified.

All remaining allocated memory blocks are automatically freed when the program ends.


  *Buffer = AllocateMemory(1000)
  PokeS(*Buffer, 0, "Store this string")
  Debug "Buffer size: " + MemorySize(*Buffer)
  *NewBuffer = ReAllocateMemory(*Buffer, 2000) ; need more memory
  If *NewBuffer
    Debug "New buffer size: " + MemorySize(*NewBuffer)
    Debug "The old content is still here:"
    Debug PeekS(*NewBuffer, 0)

See Also

AllocateMemory(), FreeMemory(), MemorySize()

Supported OS


<- PokeW() - Memory Index