Mac OS X doesn’t display disk space used by swapfiles correctly

Well, it can be a bug or a feature. Whatever it is, users can be confused about reported HDD space usage.

Let’s just take a look at how the OS reports the swap file sizes.


GetInfo

<Fig.1> Get Info

According to the Get Info, it uses 12.2MB of space on my Swap partition. Hmm.. What we can figure out first is that Mac OS X doesn’t use the theoretical Virtual Memory skim. So, they use a term “swap”. For theoretical virtual memory, it should be the size of (Physical Memory + additional memory required to satisfy all memory usage ). But on a Mac, it just allocates some good-enough space for “swap-in” and “swap-out”

Anyway, then let’s figure out how the Activity Monitor says and how much it actually takes.

ActivityMonitor<Fig.2> Activity Monitor

Hmm.. Isn’t it strange? The virtual memory space used by iPhoto is 1.28GB. Although there are other application programs, if we assume that there is only iPhoto, Safari and Finder unning, the it should be 512MB of my physical memory + some space allocated on HDD for satisfy the amount of memory space which can’t be covered by 512MB.

Then 1.29GB + 1.05GB + 852.45- 512MB is around well over 2GB. But it still shows that only 12.51MB.

Hmm.. but.. there is one more information there, Space Tree. What is that? 1.2GB.. Hmm.. it looks like actual “total space” used by swapfiles. No. It was not Space Tree but Space Free. I set my Swap partition to 1.25GB.

Let’s take a look at other information.

ActivityMonitor<Fig.2> Activity Monitor

(67108864 + 67108864 )+ 134217728 + 268435456

=  (134217728 + 134217728 ) + 268435456

=  268435456 + 268435456

= 2*268435456

Therefore, it is

(2*268435456 / 1024 ) /1024 = 512MB

Hmm.. interestingly, the total swapfile sizes equals to actual physical memory size. ( My iMac has 512MB of RAM.)

I don’t believe that the sum of swapfiles are just to reflect the content of its physical memory. It can’t be by looking at the VM size the Activity Monitor shows.

It should be the space which is swapped out from memory. So, the total content should be the one in physical memory + swapfiles.

However, it is still strange.

  1. Why is there differences between the summation of total VM size reported in the Activity Monitor and the actual total of swapfiles’ size? ( the sized in Virtual Memory column)
  2. Why is there difference between the space utilized on Activity Monitor or Get Info  12.2MB and 12.51MB. (I guess they meant to be same size. Just difference of approximation method.) and swapfile sizes? ( whether 1.24GB vs. 512MB or 12.51MB vs. 512MB )
  3. The Activity Monitor and the Get Info doesn’t actually display “Available” and “Used” correctly. It seem to omit the swapfiles’ size from its calculation.

Is there anyone figure out why there are such differences?

NOTE : I couldn’t decide this post should be posted to my HotPotato blog or not. Because this issue is not directly related to programming, my HotPotato blog can be better. However, if someone intends to write codes around virtual memory, then probably this information can be helpful. So, I decided to write this post here.

One response to this post.

  1. Posted by chad on May 27, 2010 at 11:26 AM

    You can get human-readable file sizes more easily with:

    du -hc *

    Reply

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: