Check available RAM

Discussion created by lpcware Employee on Jun 15, 2016
Latest reply on Jun 15, 2016 by lpcware
Content originally posted in LPCWare by Muis on Sun Jan 20 04:29:00 MST 2013
Im getting a lot of hard-faults in my project lately, and I suspect its because of the system running out of RAM (I dont know how to see some kind of reason-code for the hard-fault, so I can only assume).

Is there an ARM instruction that returns how much memory the system has left? So I can periodically print that out for debug purposes, and see if its getting too low? I know I could write wrappers for the malloc()/free() functions, but that doesnt tell me anything, because RAM will also be occupied by static arrays in my code, which would not be counted with a malloc-wrapper.