how to get memory occupy rate in programme?

I need to monitor the memory occupy rate in programme,just like the monitor tools in qnx,how to do?

Look at the source of pidin.