DosAllocMem can be used to reserve, or reserve and commit, linear address space for a private memory object.

The operating system allocates a range of private pages large enough to fulfill the specified allocation request from the private virtual-address space of the subject process. The base address of the object is returned in the ppb parameter.

The allocated memory object is rounded up to a multiple of 4KB in size.

The committed memory allocated by DosAllocMem can be swapped.

Any access protection can be applied to committed pages within a private memory object. Committed pages are initially allocated and backed by demand pages. The first attempt to read or write the page causes a page of zeros to be created.

If a failure occurs during the allocation, no pages are allocated, and an appropriate error code is returned.

With the Intel 80386 processor, execute and read access are equivalent. Also, write access implies both read and execute access.

The guard-page attribute is intended to provide automatic stack-growth and stack-limit checking. An application may also use it in other data structures.

Reserved pages that are not committed are given an access protection of "no access".

Note: DosAllocMem and DosAllocSharedMem both allocate a block of memory of the size requested rounded up to the nearest page. On OS/2 Warp, the system allocates a 64K object without attributes on every allocation.

For example, for a DosAllocMem call with a size of 1, the system allocates a 4096-byte block of committed memory plus 61440 bytes without attributes.

Note:

When you allocate a memory object with the PAG_EXECUTE attribute, it is implied that this memory object also has the PAG_READ attribute. However, when querying the attributes of a memory object, you will get the following results:


[Back] [Next]