return the size of the largest contiguous block of memory available
#include <malloc.h> size_t _memmax( void );
The _memmax() function returns the size of the largest contiguous block of memory available for dynamic memory allocation in the near heap (the default data segment).
In the tiny, small and medium memory models, the default data segment is only extended as needed to satisfy requests for memory allocation. Therefore, you need to call _nheapgrow() in these memory models before calling _memmax() in order to get a meaningful result. |
The size of the largest contiguous block of memory available for dynamic memory allocation in the near heap. If this is 0, then there's no more memory available in the near heap.
#include <stdio.h> #include <malloc.h> void main() { char *p; size_t size; size = _memmax(); printf( "Maximum memory available is %u\n", size ); _nheapgrow(); size = _memmax(); printf( "Maximum memory available is %u\n", size ); p = (char *) _nmalloc( size ); size = _memmax(); printf( "Maximum memory available is %u\n", size ); }
produces the output:
Maximum memory available is 0 Maximum memory available is 62700 Maximum memory available is 0
WATCOM
Safety: | |
---|---|
Interrupt handler | No |
Signal handler | No |
Thread | Yes |
calloc(), _freect(), _memavl(), _heapgrow(), malloc()