Type a page name and press Enter. You'll jump to the page if it exists, or you can create it if it doesn't.
To create a page in a module other than kernel32, prefix the name with the module name and a period.
By default, the allocated memory is not zeroed. Use the LMEM_ZEROINT flag to zero the memory.
If a zero pointer is returned, the system is out of memory and you should throw an OutOfMemoryException.
Once allocated, use the LocalFree function to free memory allocated with this function. If you do not do this, you have created a memory leak.
Tips & Tricks:
Please add some!
Sample Code:
The following method wraps LocalAlloc in order to allocate a zeroed memory block of the specified size:
public IntPtr Alloc(int size) {
// Allocate the memory, zeroing it in the progress
IntPtr memPtr = LocalAlloc(LocalMemoryFlags.LPTR, new UIntPtr((uint)size));
// Throw an OutOfMemoryException if out of memory
if (memPtr == IntPtr.Zero)
throw new OutOfMemoryException();
return memPtr;
}
Note that this sample uses the LocalMemoryFlags enumeration listed above.
A list of flags describing the allocation of memory on the local heap.
3/16/2007 7:42:29 AM - Tripwire-80.60.254.37
Frees the specified local memory object and invalidates its handle.
8/27/2008 3:05:46 PM - -151.145.238.91
Allocates the specified number of bytes from the heap.
7/6/2008 2:54:09 AM - -121.102.64.14
A list of flags describing the allocation of memory on the local heap.
3/16/2007 7:42:29 AM - Tripwire-80.60.254.37
Please edit this page!
Do you have...
helpful tips or sample code to share for using this API in managed code?
corrections to the existing content?
variations of the signature you want to share?
additional languages you want to include?
Select "Edit This Page" on the right hand toolbar and edit it! Or add new pages containing supporting types needed for this API (structures, delegates, and more).