How can we measure the amount of memory consumed by a code in Arduino Due

I want to make a comparison of the amount of memory usage on different platforms. How can I measure the memory used by a particular code in Arduino Due.

Please help me.

Thanks in advance