DOS/4G

Tenberry Home

Consulting Services

Order DOS/4G

DOS/4G FAQ

Release Notes

DPMI Spec

* * *

DOS/4GW

DOS/4GW Pro

DOS/4G
for Watcom

DOS/16M

DOS/4G and DOS/4GW FAQ:
Memory Management


[Previous Section] * [Index of FAQ] * [Next Section]
  1. I'm using WATCOM 9.5 and DOS/4G 1.96. Are there problems with the malloc() and realloc() functions? They seem to be failing prematurely.
  2. Why can't I access all 128MB of physical memory available on my machine?
  3. How can I allocate a block of memory in protected mode that doesn't cross a page boundary?

1. I'm using WATCOM 9.5 and DOS/4G 1.96. Are there problems with the malloc() and realloc() functions? They seem to be failing prematurely.

We recommend that you use WATCOM 9.5b or later, together with DOS/4G 1.97 or later, to avoid memory fragmentation problems which plagued some earlier versions.


2. Why can't I access all 128MB of physical memory available on my machine?

DOS/4G is currently limited to 64MB of physical memory. We expect to be updating the DOS extender to use the extended XMS and VCPI calls that allow access to greater than 64MB but currently, you must use virtual memory if you need access to more than 64MB of memory.


3. How can I allocate a block of memory in protected mode that doesn't cross a page boundary?

If you want to access full pages on page boundaries, you can try: typedef unsigned long ulong;
int *bufp;
int *blockp:
#define BLOCKSIZE_I_WANT 8092 /* or whatever */
#define PAGESIZE 4096 /* must be power of 2 */
#define PSM1 (PAGESIZE - 1)
bufp = malloc(BLOCKSIZE_I_WANT + PSM1);
blockp = (int *) (((ulong) bufp + PSM1) & ~PSM1);

Then blockp will point to a page aligned buffer. When you are through with the block, be sure to free(bufp);, rather than blockp, since bufp is what malloc returned.


[Previous Section] * [Index of FAQ] * [Next Section]
Last modified 2003.02.06. Your questions, comments, and feedback are welcome.