used memory on device

I was wondering if there was a way to see how much memory is used on a device?

I can see how to find the MAX_MEM_SIZE, but I want too be able to calculate how much is actually free for better management of my data caching structure?