Is there any easy way to get the heap size after I call init_mempool and have called malloc several times. I want to see how much memory is left. Mark
"Then how do you know you have enough?" That's the crux of it! With PC (and similar) targets, the programmer doesn't know how much memory will be available to the program each time it is run - it will depend on the specific configuration of the particular PC being used, and on what other things are also using memory. Therefore dynamic allocation is useful in such environments. In embedded systems (especially those suited to 8051s), this is seldom the case: the memory size is usually fixed in the hardware design (or there may be a small number of variants), and the software runtime environment will usually be known at build-time. Of course, there are exceptions - but that's the way it usually is!