You can ask for warnings as the program approaches running out of memory space, by calling memory_warnings
. This tells malloc
to check memory usage every time it asks for more memory from the operating system. This is a GNU extension declared in `malloc.h'.
The argument start says where data space begins, in memory. The allocator compares this against the last address used and against the limit of data space, to determine the fraction of available memory in use. If you supply zero for start, then a default value is used which is right in most circumstances.
For warn-func, supply a function that malloc
can call to warn you. It is called with a string (a warning message) as argument. Normally it ought to display the string for the user to read.
The warnings come when memory becomes 75% full, when it becomes 85% full, and when it becomes 95% full. Above 95% you get another warning each time memory usage increases.