 |
 |
Why does OS X swap when there's Inactive Memory available?
|
 |
|
 |
|
Professional Poster
Join Date: May 2001
Status:
Offline
|
|
I'm running Leopard Yeah I know that's borderline Dark Ages but my PowerBook is still quite functional for how I use it on a daily basis. The main issue I have with it is that Safari 5 can bog down pretty bad. It starts off very fast and then like a lot of other Safari users experience ... it gets to the point where it's beach ball city. Clearing out the cache helps a bit. Shutting down Safari and restarting helps a bit. But only to a point. A full reboot of the laptop always brings back the snappy. Now what I notice when Safari starts to get slow is that Activity Monitor shows very little Free memory and a Swap Used value that most definitely not 0. For example ....
Setup
PowerBook G4 1.33 Ghz
2 GB RAM
OS X 10.5.8
Open Apps
Safari
Entourage 2008
Address Book
iCal
Mail
MS Remote Desktop
Adium
Calculator
TextEdit
Activity Monitor
I'm in Safari and Entourage 80% of the time. 10% Remote Desktop. 10% everything else. I just rebooted yesterday and Safari ran fine. But this morning it's starting to bog down again. Not to the point where I'm ready to thrown my laptop out of a window ... but it's definitely starting to get sluggish. So the million dollar question is why do my memory stats look like this?
Free: 54.62 MB
Wired: 211.64 MB
Active: 1.11 GB
Inactive: 647.76 MB
Used: 1.95 GB
Swap Used: 215.27 MB
The strange thing is that I have plenty of Inactive memory and one would think that OS X would release some of that before resorting to the swap file .... but it's not. What gives?
OAW
|
|
|
| |
|
|
|
 |
|
 |
|
Posting Junkie
Join Date: Oct 2005
Location: Houston, TX
Status:
Offline
|
|
1) You may not have had available memory at some point.
2) There's more useful things to put in memory than some program you're not using.
3) Free memory is a complete waste.
|
|
|
| |
|
|
|
 |
|
 |
|
Clinically Insane
Join Date: Mar 2001
Location: yes
Status:
Offline
|
|
What you are looking at is a snapshot, and once swap space is claimed it isn't given back until the next reboot. It doesn't mean that you are using swap currently, but at some point swap was requested.
|
|
|
| |
|
|
|
 |
|
 |
|
Moderator 
Join Date: Mar 2004
Location: Copenhagen
Status:
Offline
|
|
Originally Posted by besson3c
What you are looking at is a snapshot, and once swap space is claimed it isn't given back until the next reboot. It doesn't mean that you are using swap currently, but at some point swap was requested.
So this would also explain how swap can sometimes exceed the size of the actual drive, then? It just piles on the swap size as it requests more, without unpiling what it’s no longer using? I’ve had swap sizes of 4–500 GB appear on this computer, which has a 250 GB system HD, which I always thought made no sense.
|
|
|
| |
|
|
|
 |
|
 |
|
Administrator 
Join Date: Apr 2001
Location: San Antonio TX USA
Status:
Offline
|
|
Can someone remind me what each of the categories of memory under OS X means? I believe "free" is unallocated, unused memory, but what is "inactive" memory? Is it allocated but not (yet) in use? If that's the case, then it's not available for use and would of course lead to paging out. If inactive isn't simply "memory that's allocated to some process", then what does "inactive" mean here?
|
|
Glenn -----
OTR/L, MOT, Tx
|
| |
|
|
|
 |
|
 |
|
Professional Poster
Join Date: May 2001
Status:
Offline
|
|
Free: This is RAM that's not being used. Total RAM - Wired - Active - Inactive
Wired: Information in this memory can't be moved to the hard disk, so it must stay in RAM. The amount of Wired memory depends on the applications you are using.
Active: This information is currently in memory, and has been recently used.
Inactive: This information in memory is not actively being used, but was recently used.
For example, if you've been using Mail and then quit it, the RAM that Mail was using is marked as Inactive memory. This Inactive memory is available for use by another application, just like Free memory. However, if you open Mail before its Inactive memory is used by a different application, Mail will open quicker because its Inactive memory is converted to Active memory, instead of loading Mail from the slower hard disk.
Used: This is the total amount of memory used. Wired + Active + Inactive
VM size: This is the total amount of Virtual Memory for all processes on your Mac.
Page ins / Page outs: This refers to the amount of information moved between RAM and the hard disk. This number is a cumulative amount of data that Mac OS X has moved between RAM and disk space.
Tip: Page outs occur when your Mac has to write information from RAM to the hard drive (because RAM is full). Adding more RAM may reduce page outs.
Swap used: This is the amount of information copied to the swap file on your hard drive.
Mac OS X: Reading system memory usage in Activity Monitor
Now given that .... it seems to me that Inactive memory would be depleted before OS X resorts to using the swap file. Yet my machine routinely has over 600 MB of Inactive memory. If Safari is being a memory hog I'd much rather OS X grab some Inactive RAM from some open program that's sitting there idle than start using the swap file on a much slower hard drive. So this is my point and the reason for my question. I NEVER see Inactive memory depleted. Ever. But the Swap Used value eventually starts to grow and grow. It doesn't make a lot of sense to me for this to be happening. Maybe my assumption that Inactive would be utilized before OS X starts to swap is simply incorrect. I was just wondering if anyone with more technical knowledge of OS X memory management than I have knew what the deal really was and why.
OAW
(Last edited by OAW; Mar 4, 2011 at 10:49 AM.
)
|
|
|
| |
|
|
|
 |
|
 |
|
Posting Junkie
Join Date: Oct 2005
Location: Houston, TX
Status:
Offline
|
|
Originally Posted by Oisín
So this would also explain how swap can sometimes exceed the size of the actual drive, then? It just piles on the swap size as it requests more, without unpiling what it’s no longer using? I’ve had swap sizes of 4–500 GB appear on this computer, which has a 250 GB system HD, which I always thought made no sense.
I think you're confusing VM and swap. VM is address space, nothing to do with your hard drive.
|
|
|
| |
|
|
|
 |
|
 |
|
Professional Poster
Join Date: Sep 2002
Location: New York, NY
Status:
Offline
|
|
Originally Posted by besson3c
What you are looking at is a snapshot, and once swap space is claimed it isn't given back until the next reboot. It doesn't mean that you are using swap currently, but at some point swap was requested.
I don't know about Leopard, but Snow Leopard will give back swap on demand. Quit a big memory hogging app and you will see the swap used on the drive go down. No need to reboot anymore with at least Snow Leopard.
|
|
Vandelay Industries
|
| |
|
|
|
 |
|
 |
|
Professional Poster
Join Date: May 2001
Status:
Offline
|
|
Here's the bottom line that I'm asking .....
Why would Swap Used increase above 0 BEFORE Inactive has decreased to 0?
On my machine right now the former is over 500 MB while the latter is still over 600 MB. Why wouldn't OS X reclaim unused RAM before hitting the hard drive?
OAW
|
|
|
| |
|
|
|
 |
|
 |
|
Clinically Insane
Join Date: Mar 2001
Location: yes
Status:
Offline
|
|
Originally Posted by Oisín
So this would also explain how swap can sometimes exceed the size of the actual drive, then? It just piles on the swap size as it requests more, without unpiling what it’s no longer using? I’ve had swap sizes of 4–500 GB appear on this computer, which has a 250 GB system HD, which I always thought made no sense.
Yup, this is correct. I guess the logic is that since it is time consuming to create that swap space that it is best to keep it around in case it is needed again later?
|
|
|
| |
|
|
|
 |
|
 |
|
Clinically Insane
Join Date: Mar 2001
Location: yes
Status:
Offline
|
|
Originally Posted by Art Vandelay
I don't know about Leopard, but Snow Leopard will give back swap on demand. Quit a big memory hogging app and you will see the swap used on the drive go down. No need to reboot anymore with at least Snow Leopard.
According to what Activity Monitor/top reports, or are you just referring to disk space consumed?
|
|
|
| |
|
|
|
 |
|
 |
|
Clinically Insane
Join Date: Mar 2001
Location: yes
Status:
Offline
|
|
Originally Posted by OAW
Here's the bottom line that I'm asking .....
Why would Swap Used increase above 0 BEFORE Inactive has decreased to 0?
On my machine right now the former is over 500 MB while the latter is still over 600 MB. Why wouldn't OS X reclaim unused RAM before hitting the hard drive?
OAW
How do you know that it didn't do just that?
|
|
|
| |
|
|
|
 |
|
 |
|
Professional Poster
Join Date: Sep 2002
Location: New York, NY
Status:
Offline
|
|
Originally Posted by besson3c
According to what Activity Monitor/top reports, or are you just referring to disk space consumed?
Both. You can watch the swap used total in Activity Monitor drop and you can see the swap files in /var/vm disappear.
|
|
Vandelay Industries
|
| |
|
|
|
 |
|
 |
|
Clinically Insane
Join Date: Mar 2001
Location: yes
Status:
Offline
|
|
Originally Posted by Art Vandelay
Both. You can watch the swap used total in Activity Monitor drop and you can see the swap files in /var/vm disappear.
If that is true, I believe that is pretty unique. I have not seen this in Linux, FreeBSD, or Solaris.
|
|
|
| |
|
|
|
 |
|
 |
|
Moderator 
Join Date: Mar 2004
Location: Copenhagen
Status:
Offline
|
|
Originally Posted by mduell
I think you're confusing VM and swap. VM is address space, nothing to do with your hard drive.
You’re absolutely correct, I was thinking of VM, not swap. My bad.
|
|
|
| |
|
|
|
 |
 |
|
 |
|
|
|
|
|

|
|
 |
Forum Rules
|
 |
 |
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
|
HTML code is Off
|
|
|
|
|
|
 |
 |
 |
 |
|
 |
|