Using top, I manually measured the following memory usages at the specific points designated in the comments of the following code block:
top
x <- mat