Memory Allocation Problems
If you run out of memory in the heap under PCDOS or XENIX, there are several reasons why this might have occurred:
- If you are using a small or medium memory model, all of your global variables, static data, stack, and heap must fit within 64K. If you have many global variables, including global data, static data, stack and heap, you may be running out of heap. Using a large data memory model will probably solve the problem.
- You may be repeatedly using a routine that calls mem_stblank(). The mem_stblank() function makes a call to mem_get() to allocate memory for a string. You should free this memory explicitly with a call to mem_free() at the end of the routine. If mem_stblank() is called more than once for the same variable without an intervening call to mem_free() for that variable, the pointer to the first block of memory is lost. The first block of memory can never be recovered.
- You may be using pic_def() in an unsupported manner. The memory allocated by pic_def() is automatically recovered when fm_free() is explicitly called. A common mistake is to use pic_def() to create a string that is then used in a bg_txtdef() call. When used in this manner, the memory allocated by pic_def() will not be freed when the form is freed.