今天因為 Mac 上的 Outlook 收到了一封很大很大的信,

結果導致電腦超級頓,風扇也轉得超級大聲的,

作每件事情都很卡,包括去砍掉那封信...

不過一開始出現電腦很頓的狀況時,還沒意識到是信箱的問題,

只覺得一開 Outlook 就開始出問題了,這樣應該怎麼 debug 呢?

 

很直覺地打了 Linux 下常用的 atop 指令,發現 Mac 上是沒有的...

查了一下,Mac 預設就有 Activity Monitor 這個 GUI 工具,

和 top 這個 command line tool 可以觀察 CPU 的使用率

 

1. 使用 GUI 工具:Activity Monitor

參考資料: OS X: Activity Monitor shows one CPU Usage graph on systems with more than four cores

打開 Launchpad (F4) > 搜尋並執行 Activity Monitor,可以看到類似下面的畫面:

Screen Shot 2015-01-05 at 下午3.39.34  

 

按下 % CPU 那欄依照 CPU 使用率排序,就能找出目前吃資源的 process 囉

 

2. 使用 command line 工具:top

參考資料:

  - Monitoring System Activity on the Command Line

  - Getting CPU information from command line in Mac OS X

如果比較喜歡 command line 工具的話,可以用內建的 top 工具

執行 top -o cpu 就可以依照 CPU 使用率排序如下:

testuser@localhost  top -o cpu

Processes: 232 total, 3 running, 15 stuck, 214 sleeping, 1296 threads 15:43:22
Load Avg: 2.24, 1.84, 1.69 CPU usage: 19.7% user, 3.66% sys, 77.26% idle SharedLibs: 19M resident, 13M data, 0B linkedit.
MemRegions: 36430 total, 3290M resident, 133M private, 1018M shared. PhysMem: 7450M used (1508M wired), 8932M unused.
VM: 551G vsize, 1063M framework vsize, 0(0) swapins, 0(0) swapouts. Networks: packets: 606109/252M in, 64218/20M out.
Disks: 173631/4057M read, 105421/3566M written.

PID COMMAND %CPU TIME #TH #WQ #PORT MEM PURG CMPR PGRP PPID STATE BOOSTS %CPU_ME %CPU_OTHRS UID FAULTS COW MSGSENT
1434 Google Chrom 57.2 05:32.38 48/1 3 725+ 155M- 1268K 0B 1434 1 running *0[644+] 0.40840 0.00000 595608144 1265377+ 317399 2358849+
2467 mdworker 8.8 00:00.25 6 4 50 2800K+ 0B 0B 2467 1 stuck *0[1] 0.00000 6.81429 595608144 3827+ 183+ 174+
2468 mdworker 8.8 00:00.25 5 3 45 2564K+ 0B 0B 2468 1 stuck *0[1] 0.00000 7.41535 89 3734+ 183+ 160+
1184 Terminal 2.5 00:06.79 10 4 415+ 22M+ 12K 0B 1184 1 stuck *0[296+] 0.76514 0.03183 595608144 16298+ 688+ 47408+
272 WindowServer 2.1 03:17.59 4 0 525 81M 7700K 0B 272 1 sleeping *0[1] 0.06684 0.00000 88 209928+ 5407 6316370+
2466 top 2.0 00:00.33 1/1 0 21 2720K+ 0B 0B 2466 1187 running *0[1] 0.00000 0.00000 0 18897+ 88 152895+
0 kernel_task 1.7 03:08.12 106/4 0 2 1165M- 0B 0B 0 0 running 0[0] 0.00000 0.00000 0 18143 0 8631772+
1317- iCoreService 1.0 01:21.69 13 2 41 60M 0B 0B 1317 1 sleeping *0[1] 0.00000 0.00000 0 16684 173 3510+
1462 Google Chrom 0.8 00:21.57 13 0 124 189M 0B 0B 1434 1434 sleeping *0[26] 0.00000 0.00000 595608144 95336 1454 7069+
862 pbs 0.7 00:00.12 6 5 46+ 2228K+ 0B 0B 862 1 sleeping *0[11+] 0.00000 0.72521 595608144 3925+ 125 508+
1453 Google Chrom 0.6 00:03.77 12 0 123 29M- 0B 0B 1434 1434 sleeping *0[24] 0.00000 0.00000 595608144 41396+ 1425 5941+
1446 Google Chrom 0.5 00:50.10 15 0 143 25M 12K 0B 1434 1434 sleeping *0[24] 0.00000 0.00000 595608144 50589 1424 90380+
963 ATMemoryClea 0.3 00:44.32 3 0 139 10M 4096B 0B 963 1 sleeping *0[393+] 0.00000 0.00664 595608144 5950 300 105674+
850 distnoted 0.2 00:03.11 7 5 211+ 4340K+ 0B 0B 850 1 sleeping *0[1] 0.00000 0.22853 595608144 4033+ 92 37375+
17 syslogd 0.2 00:24.76 7 6 170 1828K 0B 0B 17 1 sleeping 0[2006] 0.00126 0.00000 0 5038 74 22057+
79 hidd 0.2 00:17.59 6 1 91 2060K 0B 0B 79 1 sleeping *0[1] 0.00000 0.00000 0 3919 136 455905+
36 mds 0.2 00:16.22 7 4 244+ 33M+ 0B 0B 36 1 sleeping *0[1] 14.2929 0.05706 0 101503+ 685 97735+
1441 Google Chrom 0.2 00:43.32 16 1 148 135M+ 0B 0B 1434 1434 stuck *0[25] 0.00000 0.00000 595608144 121047+ 1434 74723+
1454 Google Chrom 0.2 00:03.11 11 0 126 63M+ 2868K 0B 1434 1434 sleeping *0[25] 0.00000 0.00000 595608144 46906+ 1442 5193+
1413 BetterTouchT 0.2 00:09.95 8 3 195 10M 16K 0B 1413 1 sleeping *0[1208+] 0.00982 0.02837 595608144 9802 663 583206+
26- iCoreService 0.1 00:03.19 32 5 258+ 4916K+ 0B 0B 26 1 sleeping *0[1] 0.00000 0.00000 0 3783+ 219 12051+
926- Dropbox109 0.1 00:28.03 39 0 229 66M 60K 0B 926 1 sleeping *0[271] 0.00000 0.00000 595608144 115638 14792 9374
449 mds_stores 0.1 00:16.07 7 5 64+ 42M+ 82M 0B 449 1 sleeping *0[1] 0.00000 0.08453 0 214733+ 1565 98094+
54 discoveryd 0.1 00:33.68 19 17 104 12M 0B 0B 54 1 sleeping *0[1] 0.00000 0.00000 65 6579 148 1991
20 fseventsd 0.0 00:04.68 8 0 205 4784K 0B 0B 20 1 sleeping *0[1] 0.00000 0.00000 0 8579 90 5210
2444 Google Chrom 0.0 00:03.16 13 0 128 81M 972K 0B 1434 1434 sleeping *0[26] 0.00000 0.00000 595608144 45393 1466 4543+
83 distnoted 0.0 00:00.56 6 4 84+ 1304K+ 0B 0B 83 1 sleeping *0[1] 0.00000 0.05171 241 1636+ 93 11651+
51 nxserver.bin 0.0 00:14.44 8 0 105 43M 0B 0B 51 1 sleeping *0[1] 0.00000 0.00000 499 20025 1263 529200+
1457 Google Chrom 0.0 00:09.77 13 0 128 135M 632K 0B 1434 1434 sleeping *0[27] 0.00000 0.00000 595608144 58756+ 1462 13817+
1205- Microsoft Da 0.0 00:16.04 3 0 119 285M 0B 0B 1205 1 sleeping *0[318] 0.00000 0.00000 595608144 686531+ 1278 19529
1102- dbfseventsd 0.0 00:01.86 1 0 7 4276K 0B 0B 926 1100 sleeping *0[1] 0.00000 0.00000 0 1392 34 10
2300- LINE 0.0 00:08.46 14 0 417 37M 0B 0B 2300 1 sleeping *0[430] 0.00000 0.00000 595608144 62243 2068 14424

 

 

文章標籤
全站熱搜
創作者介紹
創作者 ephrain 的頭像
ephrain

亂打一通的心情日記

ephrain 發表在 痞客邦 留言(0) 人氣(1,294)