jim. said:
It amazes me how prevalent threads like this are on most any Unix-ish OS board. It is almost up there with the people who detect big "memory leaks" only using top and Activity Monitor.
I guess that some people just won't learn about how memory is used and released, and will just continue to complain...
You have a good point about not understanding how virtual memory works, and when it's actually in use vs. simply allocated. A tiny program can demonstrate this fallacy:
Code:
#include <stdlib.h>
#include <unistd.h>
int main(){
unsigned long size = 1024 * 1024 * 3;
char *junk = (char *)malloc(size*1024);
sleep(10);
return 0;
}
Copy this into a file called
mem.c, compile it with the command
make mem and run it (
./mem &), then switch to Activity Monitor. You'll see that it's supposedly using 2 gigs of virtual memory. You can run any number of instances of the program simultaneously and you'll never run out of memory, virtual or real.
I ran 30 instances of the program simultaneously with no ill effects on my system. The Unix command
top (Activity Monitor for the command line) reported:
Code:
MemRegions: num = 13078, resident = 194M + 13.0M private, 117M shared
PhysMem: 94.1M wired, 137M active, 307M inactive, 539M used, 100M free
VM: 67.6G + 0B 2118533(0) pageins, 2614924(0) pageouts
PID COMMAND %CPU TIME #TH #PRTS #MREGS RPRVT RSHRD RSIZE VSIZE
15178 top 0.0% 0:00.29 1 16 24 372K 488K 748K 27.1M
15175 mem 0.0% 0:00.01 1 11 21 80K 396K 356K 2.03G
15174 mem 0.0% 0:00.01 1 11 21 80K 396K 356K 2.03G
15173 mem 0.0% 0:00.01 1 11 21 80K 396K 356K 2.03G
15172 mem 0.0% 0:00.01 1 11 21 80K 396K 356K 2.03G
.... and so on
HOWEVER, all of that said, let me get to my point.
Seems like an alarming number of people here like to dismiss any claims that OS X may not be operating at peak efficiency. It's easy to tell other people that they don't understand how it works, so they're obviously wrong. Sometimes that's the case, but I feel like many here aren't even willing to entertain the possibility that the person has a legitimate complaint.
Personally, I'm getting sick of OS X's poor memory handling. I have 640 MB of memory in my machine (which should be more than enough, according to the many who say that 256 MB or less "runs just fine") and it is slow as heck. I keep Safari, Terminal, and iTunes open always, with a smattering of other applications open at any given time.
As far as I can tell, Safari is the biggest culprit. After browsing for a few days, I have 5 windows open and a total of 11 tabs among them. Safari's virtual memory is just over 1,000 MB. I understand that this doesn't necessarily mean it's using all of that, but the performance I get suggests that it comes close. I just closed a window with 2 tabs and it took over 2 minutes for Safari to become responsive again. During this time, the disk was thrashing incredibly. Safari sits around 73 MB of real memory used, rarely changing, but according to the number of Page-ins/outs during that operation, it's paged in about 40-50 MB and out about 20 MB. Why hasn't OS X paged out other applications that I haven't used in hours or days but are still open, to give Safari more real memory? And I find Safari's memory hogging to be rather ironic, given that it started life as a "fast and light" alternative.
By way of comparison, my SGI at work runs Mozilla 1.4. I have 8 windows open and 67 tabs among them. Total memory usage of Mozilla? 48 MB. Even if you argue that graphics memory is offloaded to the window server, that's only using 71 MB, and I have a lot more going on than Mozilla on that machine.
I finally broke down and ordered a pair of 512 MB sticks yesterday to max out my home machine with 1.5 GB. I can't take it anymore. When switching users from my wife's account to mine, the whole screen often doesn't update for 20-30 seconds as the disk thrashes me back into memory. Maybe I'm a power user, but I don't think that what I do on a daily basis should suck up so much memory and cause so much disk thrashing. I spend most of my time in Terminal, with Safari for surfing and iTunes for music/iPod stuff. I'm not running huge simulations on this machine or crunching lots of data. I don't do development on it because my FreeBSD PC is so much faster at compiling. What gives??