I know two ways to check the memory usage on Linux by using the free command and with cat /proc/meminfo. If you want to use them in a sketch, you can use the system() function, and then send the output into the serial monitor. You would have to use them like this:
//to use free command
system(“free > /dev/ttyGS0”);
//to use the meminfo
system(“cat /proc/meminfo > /dev/ttyGS0”);
Let me know if this is what you are looking for.