1

My wife's new iMac is behaving rather oddly. Despite being a pretty powerful machine, it's rather slow and laggy. I looked into it, and it seems her swap memory is maxing out, even though there's plenty of RAM left:

screenshot of htop output

Yet my Mac Pro looks like this:

screenshot of htop output

This happens consistently, causing the machine to significantly underperform. Is there something wrong with the system, perhaps?

1

This is all anecdotal, tested using a sample size of 2, so barely counts as experiment...

Restart the Mac, it's been up 12 days.

That would be fine for a machine with a lot of RAM, but it's going to hit a low RAM machine harder.
I'd say the simple solution would be to double the RAM.
Two of the machines here are always on, the one with only 10GB RAM used to slow down after only a few days [it now has 26GB & no longer does that], the one with 64GB really never slows down.

I think the used swap figure only gets reset at reboot, btw. I'm not sure it's necessarily an indicator of current activity [but I'm certainly open to correction on that]

1

I do not know which program you used to generate the output in the screenshot, but assuming it outputs the ordinary figures such as for example Activity Monitor or top would do - the reason for the seemingly erraneous swap usage is simply one of time.

Imagine that a process on your Mac allocates 12 GB of RAM. The system hasn't got 12 GB of free RAM, so it moves something to swap and gives the process its 12 GB of RAM.

A bit later, the process frees the 12 GB of RAM (i.e. deallocate them). The system now has a lot of free RAM, but is still using a lot of swap space.

You could argue that the system should move everything from swap into RAM, but doing so is slow and "expensive" in terms of system resources. The system cannot know if you would need the stuff that is in swap first, or you rather want to have free RAM for something else. Therefore it generally opts to keep stuff in swap, and only move it into RAM as necessary.

The solution for your problem is to monitor continually over a period of time (for example from boot) to figure out, which process is actually using a lot of RAM for a limited amount of time.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .