Quite simply, how can I tell how much free memory I have in a memory pool? I've created a memory pool, initialized it with init_mempool and use malloc & free finctions for memory management. Is there a simple way to find out how much memory is still available to be allocated? I have a fairly dynamic application and I would like to insert some degugging triggers if memory gets low. I thought of simply using malloc to request a block of say 200 bytes and then free it again. Could do this once a second and generate a low memory error if it fails. Seems a bit clunky, is there an easier way that I have missed?? Thanks, Bryan Green.
"Most of the memory is allocated at startup, while small amounts are malloc/free while app is running." Do these 'small amounts' plus your initial big blob add up to more RAM that is available? If not, perhaps you could just malloc up suitably sized bits of memory once and keep them around for the duration of the program? If your memory allocation/deallocation follows a malloc->free->malloc->free sequence how about using a single shared block? Perhaps you could dump dynamic allocation altogether?