FreeMem
Releases a block of memory previously obtained from AllocMem.
Syntax: FreeMem MemPointer
- MemPointer
- required LongPtr. The address returned by a previous call to AllocMem.
The pointer is invalid after the call returns. Passing a pointer that did not come from AllocMem, or one that has already been freed, has undefined behaviour. A MemPointer of 0 does nothing.
Common Errors
| Error | When |
|---|---|
94 (&H5E), Invalid use of Null | MemPointer is Null |
Example
This example allocates a buffer, uses it, and then releases it with FreeMem.
Dim buf As LongPtr = AllocMem(256)
' ... write and read buf ...
FreeMem buf ' release the block; buf is invalid after this point
See Also
- AllocMem function