add memory usage monitoring to example