Memory monitoring function (for Linux only)