You can make a difference in the Apple Support Community!

When you sign up with your Apple Account, you can provide valuable feedback to other community members by upvoting helpful replies and User Tips.

Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

Lion - Memory Usage Problems

Why is Lion using all 4GB of RAM running Mail, Safari (2 tabs), and iTunes? Snow Leopard was bad enough at handling memory, eating up every available byte and Lion seems to be arbitrarily using even more RAM. Windows 7 has zero problems handling RAM, there's no reason OS X shouldn't be able handle memory properly.


Can someone explain what Apple is doing here? I'm at a total loss. For users who just need Safari, Mail, and iTunes... I guess this works. But how am I expected to reliably run Logic, Final Cut, or Aperture with OS X using every available resource for Web Surfing, E-mail, and Music. This is totally unacceptable for a multi-million dollar software company greated towards professionals as well as consumers.


The following responses are not acceptable by the way:


  • Buy more RAM - I did that already, it will eat up 2/4/8GB, doesn't matter. Not to mention Apple still sells numerous 2/4GB confirgurations.
  • Buy a newer/more powerful Mac - this is a improper handling of memory issue, not a hardware issue.


I'd really love some insight into this. Thanks for reading.

MacBook Pro, Mac OS X (10.7), 13" (late-2009)

Posted on Jul 21, 2011 5:45 AM

Reply
957 replies

Sep 22, 2011 6:26 AM in response to Michelasso

All right, I have eventually found the system command to show the virtual memory usage along other kernel values, sysctl:


This is what the man page says:


Information about the system's swap space usage may be obtained with:
sysctl vm.swapusage


Running it from terminal this is what I've got:


$ sysctl vm.swapusage

vm.swapusage: total = 1024.00M used = 543.50M free = 480.50M


Which matches exactly the iStat Menus and Activity Monitor "Swap Used" value. One can check himself as soon as some paging activity starts. These are the swap files present in the system at that time:


$ ls -l

total 8388608

-rw------T 1 root wheel 3221225472 22 Set 08:57 sleepimage

-rw------- 1 root wheel 67108864 21 Set 09:38 swapfile0

-rw------- 1 root wheel 67108864 22 Set 14:30 swapfile1

-rw------- 1 root wheel 134217728 22 Set 14:30 swapfile2

-rw------- 1 root wheel 268435456 22 Set 14:30 swapfile3

-rw------- 1 root wheel 536870912 22 Set 14:30 swapfile4


Their total size is 1GB indeed. I hope that this clears up few things once and for all.

Sep 22, 2011 7:34 AM in response to mightymilk

Wow. This thread is either:


a) an example of what is best about online discussion forums, where anybody can participate and express their oppinions on any topic.


OR,


b) an example of how a simple problem report (i.e. Safari using huge amounts of memory in Lion), can morph into never ending discussion on virtual memory, swap, and inner workings of Darwin kernel, Safari, Lion etc. etc.



I just have one question for everyone. Does anybody actually believe that there is NO problem with Safari in Lion?

Sep 22, 2011 3:36 PM in response to mightymilk

The process displayed on the Activity Monitor "Safari Web Content" is hogging 99% of CPU intermittently. Have OSX 10.6.8, 4GB Ram, 2.4 Core 3 Duo, MacBook Pro. Oddly, compared with others here, it is not hogging memory, only 256 MB at most.


I have owned the MacBook for about 6 months. This problem first occurred about a month ago, and it is getting worse.


Today I updated Adobe Flash. Then I deleted the one Safari extension I had installed.


Ran fine for a half hour, while I was doing Yahoo Mail and checking the Apple support website, Then everything came to a halt with 99% CPU consumption. Closed Safari, reopened and it was OK.


So, these are NOT the problem, tried them all today:

-Lion (don't have it yet)

-Extensions (deleted all)

-Adobe Flash (updated it today)

-Needing to empty Safari Cahche (did that, too)


I am going to try switching to Firefox which I used prior on a PC and liked. I can't deal with this day in and out.

RR


-

Sep 22, 2011 3:49 PM in response to uncas_ripley

I don't think anyone can say there is no problem for anyone, as always some people are experiencing issues. I certainly don't believe its Safari thats got the problem after my experience tonight. /___sbsstatic___/migration-images/162/16210625-1.jpg


Check out the stats in the image attached. Now i'm used to rebooting safari for the moment, geektool helping me out so i can always check my ram usage but itunes was using 1.5gb of ram all of a sudden and nigh on 100% processor.


I have a few addons to my system that improve my productivity that until now i have not been willing to part with even for science but i may have to see if something is causing the problem.


This was the first time anything but safari has caused issues since getting Lion and i always have iTunes open and as always was simply playing a song, nothing else. No videos or adding of anything, no hard drives mounted just an iphone charging.


Whatever is wrong with Lion at the moment thats causing these insane spikes, there are clearly a few issues.

Lets just pray to Steve/Tim that 10.7.2 is the saviour.

---------------

iMac, fully updated lion, 2.4 Core 2 Duo, 4gb, 320 + 1tb not mounted, 20" + 17" added. (More RAM isn't really an option at this point, nor is it necessary.)


User uploaded file

Sep 22, 2011 9:01 PM in response to Michelasso

Michelasso wrote:

Swap Used is, according to the Activity Monitor help page itself, the amount of disk space currenty used as virtual memory. Which it can't be anything else than the total of RAM pages currently swapped out to disk.

But it is something else. To see why, consider a room in a hotel used for business meetings. The room has 200 seats in it. A meeting begins. I assume you would agree that the amount of seating space currently used for the meeting is 200 seats, right?


20 people attend the meeting. This is not somehow another measure of the current seating space, just of how many of its seats currently are occupied.


It is the same with "Swap used." Like with seating space, it is the amount of disk space currently used but it isn't necessarily the number of pages currently filled.

Sep 23, 2011 3:10 AM in response to R C-R

R C-R wrote:


But it is something else. To see why, consider a room in a hotel used for business meetings. The room has 200 seats in it. A meeting begins. I assume you would agree that the amount of seating space currently used for the meeting is 200 seats, right?


20 people attend the meeting. This is not somehow another measure of the current seating space, just of how many of its seats currently are occupied.


It is the same with "Swap used." Like with seating space, it is the amount of disk space currently used but it isn't necessarily the number of pages currently filled.


? Swap used is 20 seats and the available swap space is 180 seats. That is shown by the output of sysctl


$ sysctl vm.swapusage

vm.swapusage: total = 1024.00M used = 543.50M free = 480.50M


1024 seats available, 543.5 used, 480.5 free. My idea is that the "page ins" and "page outs" numbers in Activity Monitor are giving out misleading informations. Why?


Let's take "Page outs" for example. It is the same exact number of "Pageouts" in vm_stat output multiplied by the page size (4KB). The same for "Page ins". That IMVHO is wrong because the "Pageouts" and "Pageins" in the code are counters that keep getting incremented by 1 by the pagers. vm_stat just prints those numbers. This is the code section for printing the current values (not reiterating):


snapshot(void)

{


get_stats(&vm_stat);

printf("Mach Virtual Memory Statistics: (page size of %d bytes)\n",

(int) (pageSize));


sspstat("Pages free:", (uint64_t) (vm_stat.free_count - vm_stat.speculative_count));

sspstat("Pages active:", (uint64_t) (vm_stat.active_count));

sspstat("Pages inactive:", (uint64_t) (vm_stat.inactive_count));

sspstat("Pages speculative:", (uint64_t) (vm_stat.speculative_count));

sspstat("Pages wired down:", (uint64_t) (vm_stat.wire_count));

sspstat("\"Translation faults\":", (uint64_t) (vm_stat.faults));

sspstat("Pages copy-on-write:", (uint64_t) (vm_stat.cow_faults));

sspstat("Pages zero filled:", (uint64_t) (vm_stat.zero_fill_count));

sspstat("Pages reactivated:", (uint64_t) (vm_stat.reactivations));

sspstat("Pageins:", (uint64_t) (vm_stat.pageins));

sspstat("Pageouts:", (uint64_t) (vm_stat.pageouts));

#if defined(__ppc__) /* vm_statistics are still 32-bit on ppc */

printf("Object cache: %u hits of %u lookups (%u%% hit rate)\n",

#else

printf("Object cache: %llu hits of %llu lookups (%u%% hit rate)\n",

#endif

vm_stat.hits, vm_stat.lookups, percent);


}


vm_stat.pageouts gets incremented only once in the module vm_pageouts.c (the default pager) by the VM_STAT_INCR() macro:


if (page_list[entry].dirty) {

VM_STAT_INCR(pageouts);

DTRACE_VM2(pgout, int, 1, (uint64_t *), NULL);

pgpgout_count++;

}


Please note as an additional pgpgout_count (pages paged out) counter is present.


Now, I am not able to catch where the so called "swap used" value gets updated (the source code is much bigger than what I thought). What I know is that the Universal Page List can mark as clean some dirty pages adjacent to the original one requested to be paged out, and flush them all together as a cluster of pages to the backing store (so paged out, swapped out, whatever. They are used by many as interchangeable terms in this contest) still keeping the copy of some of these pages in RAM. These pages increment the used backing store size but not the pageouts counter. Which is 1 for for each cluster of pages flushed to disk.


This would be a sort of cache (again). But since those pages are inactive and clean they would be the first to go (without the need to page them out again. They are marked clean) if free memory is needed before they get reused (and so put in the inactive list) if ever. Let's say, as usual, it would optimize I/O performances.


This would explain why the number of pages swapped out in the backing store (= swap used / page size) is superior to the pageouts counter at the beginning of the first paging out activity. But yet again it wouldn't give the answer to the original questions of this discussion.

Sep 23, 2011 3:14 AM in response to uncas_ripley

uncas_ripley wrote:


I just have one question for everyone. Does anybody actually believe that there is NO problem with Safari in Lion?

Some people do. They have 8+ GB of RAM in their machines and they are not bothered that the web browsers are requiring more and more RAM in a exponential fashion. The answer is: who cares, RAM is cheap. They are not necessarily in this discussion. I have read this many times elsewhere.

Sep 23, 2011 4:57 AM in response to Michelasso

Michelasso wrote:


uncas_ripley wrote:


I just have one question for everyone. Does anybody actually believe that there is NO problem with Safari in Lion?

Some people do. They have 8+ GB of RAM in their machines and they are not bothered that the web browsers are requiring more and more RAM in a exponential fashion. The answer is: who cares, RAM is cheap. They are not necessarily in this discussion. I have read this many times elsewhere.


Near the beginning of this thread, someone posted a screenshot from a Mac Pro with 32GB of RAM, all of it was used up and numerous applications were unresponsive. This is definitely not an issued related to the physical amount of RAM in someones machine. My MacBook Pro does the same thing whether you feed it 2/4/8GB or RAM.

Sep 23, 2011 5:28 AM in response to mightymilk

mightymilk wrote:


Near the beginning of this thread, someone posted a screenshot from a Mac Pro with 32GB of RAM, all of it was used up and numerous applications were unresponsive. This is definitely not an issued related to the physical amount of RAM in someones machine. My MacBook Pro does the same thing whether you feed it 2/4/8GB or RAM.

Then what is it? Are we the unlucky b@stards? I did everything I could to cleanup my machine. Now with the new Seagate Momentus XT HDD (the WD Blue Scorpio died. 2nd in 2 years...) I even boot in less than 20 seconds! Another 20s to resume the login.


Then after 1 or 2 hours something kicks in (usually Safari but not only), and... I get the disaster we know. I mean, I am rebooting twice a day. Leaving it on everything slows down dramatically. Thanks God for Resume and the new HDD otherwise it would be a nightmare.

Sep 23, 2011 5:40 AM in response to Michelasso

Michelasso wrote:


mightymilk wrote:


Near the beginning of this thread, someone posted a screenshot from a Mac Pro with 32GB of RAM, all of it was used up and numerous applications were unresponsive. This is definitely not an issued related to the physical amount of RAM in someones machine. My MacBook Pro does the same thing whether you feed it 2/4/8GB or RAM.

Then what is it? Are we the unlucky b@stards? I did everything I could to cleanup my machine. Now with the new Seagate Momentus XT HDD (the WD Blue Scorpio died. 2nd in 2 years...) I even boot in less than 20 seconds! Another 20s to resume the login.


Then after 1 or 2 hours something kicks in (usually Safari but not only), and... I get the disaster we know. I mean, I am rebooting twice a day. Leaving it on everything slows down dramatically. Thanks God for Resume and the new HDD otherwise it would be a nightmare.

I really don't know. I've been all over Google trying to figure it out, I'm having major performance and memory issues too. It's all over the MacRumor forums, I've seen a ton of suggestions but nothing that actually solves the problem. I'm getting ready to bite the bullet and do a clean install, as a last resort.


I've heard a lot of people suggesting some of the new features in Safari could be causing the overly high memory usage. It still doesn't explain why OS X won't return Inactive RAM to the system for use. I'm doing the same thing you're doing, Quitting/Purging/Restarting daily.


I don't even have to look at Activity Monitor to know it's paging. I'll sit there doing simple daily tasks and as soon as I notice ballons and overall sluggish performance, I launch Activity Monitor and sure enough there's about 2GB of Active RAM, 500MB of Wired RAM, and the rest is Inactive with 0 Free RAM available and the Page Out #'s just keep climbing.

Oct 12, 2011 8:42 AM in response to Adam Ullrich

I started reading this thread because my nephew is having this problem with his brand new MacBook Air. At first, it was very fast. Now Safari slows to a crawl and can't load pages. I had hoped that reading this thread would give me some ideas as to how to help him but I see that there is no consensus as to what it causing it or how to fix it for those who have it.


I just want folks who are reading this to know that not everybody using Lion and Safari is having this problem. I have a 2006 MacBook Pro, Core 2 Duo with 3 GB of RAM. I am running Safari in 64-bit mode. I have not experienced any slow-down. In fact, everything seems to run much quicker in Lion on my computer. I have noticed that the Safari Web Content process seems to be using the most RAM at any one moment. I just checked Activity Monitor with this thread open and Safari Web Content was using 240.5 MB of RAM. The next process down is always kernel_task. I have no page outs listed. I have the lastest version of Flash Player installed. I have a few extensions installed and enabled. Ad Blocker is installed but not presently enabled.


I will check back periodically to see if anybody has come up with a solution for those who are having this issue.

Lion - Memory Usage Problems

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.