[Overview][Constants][Types][Procedures and functions][Variables][Index] Reference for unit 'Intuition' (#aros)


Allocate Memory with tracking to make freeing easy.


Source position: intuition.pas line 3253

function AllocRemember(

  var RememberKey: PRemember;

  Size: LongWord;

  Flags: LongWord





Store information in this list. Must be nil for initial call.



How many bytes to allocate



Attributes (see AllocMem())

Function result

If the memory allocation is successful, this routine returns the byte address of your requested memory block. Also, the node to your block will be linked into the list pointed to by your RememberKey variable. If the allocation fails, this routine returns nil and the list pointed to by RememberKey, if any, will be unchanged.


This routine calls the Exec AllocMem() function for you, but also links the parameters of the allocation into a master list, so that you can simply call the Intuition routine FreeRemember() at a later time to deallocate all allocated memory without being required to remember the details of the memory you've allocated.

This routine will have two primary uses:

You create the "anchor" for the allocation master list by creating a variable that's a pointer to struct Remember, and initializing that pointer to NULL. This is called the RememberKey. Whenever you call AllocRemember(), the routine actually does two memory allocations, one for the memory you want and the other for a copy of a Remember structure. The Remember structure is filled in with data describing your memory allocation, and it's linked into the master list pointed to by your RememberKey. Then, to free up any memory that's been allocated, all you have to do is call FreeRemember() with your RememberKey.

Please read the FreeRemember() function description, too. As you will see, you can select either to free just the link nodes and keep all the allocated memory for yourself, or to free both the nodes and your memory buffers.


  RememberKey: PRemember;
  RememberKey := nil;
  buffer := AllocRemember(@RememberKey, BUFSIZE, MEMF_CHIP);
  if Assigned(buffer) then
    // Use the buffer
  FreeRemember(@RememberKey, True);

See also



Free memory allocated by calls to AllocRemember().



Allocate memory given certain requirements

Documentation generated on: 2017-01-10