How to know which processes uses the most resources

There are times where some processes use too much resources. You can use “ps aux” to get a list of all the processes that are currently running. But what about having them sorted? Here is one way. This works in Ubuntu Linux.

Top 10 % CPU usage

[code lang=”bash”]ps aux|sort -nr -k3|grep -v USER|head -10[/code]

Top 10 % Memory usage

[code lang=”bash”]ps aux|sort -nr -k4|grep -v USER|head -10[/code]

The following is the sample output for Top 10 % memory usage:

[code lang=”bash”]briecheese ~: ps aux|sort -nr -k4|grep -v USER|head -10
www-data 3883 2.9 14.1 107052 37176 ? S 11:44 1:46 /usr/bin/php-cgi
www-data 3882 2.9 13.8 107664 36264 ? S 11:44 1:46 /usr/bin/php-cgi
www-data 3881 1.2 13.2 106768 34688 ? S 11:44 0:44 /usr/bin/php-cgi
www-data 3884 3.1 13.1 107244 34592 ? S 11:44 1:54 /usr/bin/php-cgi
www-data 3879 1.1 11.8 106888 31160 ? S 11:44 0:40 /usr/bin/php-cgi
www-data 3880 0.9 9.5 94232 25092 ? S 11:44 0:34 /usr/bin/php-cgi
mysql 3659 3.5 6.9 277256 18200 ? Sl 09:45 6:25 /usr/sbin/mysqld –basedir=/usr –datadir=/var/lib/mysql –user=mysql –pid-file=/var/run/mysqld/ –skip-external-locking –port=3306 –socket=/var/run/mysqld/mysqld.sock
root 4103 0.2 1.0 53468 2704 ? Ss 12:44 0:00 sshd: me [priv]
me 4106 0.0 0.8 18128 2116 pts/0 Ss 12:44 0:00 -bash
www-data 3875 0.0 0.7 57440 1972 ? S 11:44 0:00 /usr/sbin/lighttpd -f /etc/lighttpd/lighttpd.conf[/code]

Percentage memory usage is the 4th column. This is useful when you need a quick overview of what’s consuming the most memory. [Thanks U-Zyn]

4 Gb RAM is a significant improvement

I never regret getting an additional 2 Gb for my memory, the improvement is significant and it delights me when applications launches quicker. I noticed the improved performance in applications such as Firefox and Photoshop. There’s a slight improvement in iTunes too I think, yes, that piece of crap.

The difference is less obvious in Windows 7 which already is pretty quick.

Upgrading the Acer Aspire One A150 netbook

It was a sudden decision to head to Sim Lim. I made several acquisitions there:

  1. Laptop memory, it’s a 677 Mhz DDR2 (1GB) SO-DIMM whatever Kingston RAM.
  2. Desktop memory, it’s a 800 Mhz DDR2 (2 GB) Kingston RAM.
  3. A SATA to USB convertor.

I opened up my Acer Aspire One bravely voiding the warranties. I own an Acer Aspire One that I gotten upon a SingNet contract renewal. It’s a netbook that came at a time I wanted to get a notebook. I treat it as a sign from the gods that I should delay a notebook purchase (to yet another year). It comes with 1GB memory, of which 512 is soldered onboard. I followed a hardware guide to open the netbook and add in new memory.

For the Acer Aspire One A150, the maximum amount of memory it can go is 1.5 GB. I chose the option to rid the 512 MB RAM and placed in a 1024 MB RAM. I don’t really know what I was doing. I hesitated before I buy but I thought, heck, it’s just 18 bucks and I’m already here so let’s get it and try it out.

Acer Aspire One A150 opened up to add memory 1
Acer Aspire One A150 opened up to add memory 1

Here’s how it look like when it’s all naked. It’s the first time I opened a notebook and I’m extra careful with everything. I didn’t follow the full instructions as it didn’t suit my model but the guide still help a lot.

Acer Aspire One A150 opened up to add memory 2
Acer Aspire One A150 opened up to add memory 2

It become apparent that Acer designed the netbook without upgrading concerns in mind. The DDR2 slot is located all the way inside, you have to unscrew everything, rid the keyboard, the daughter board and sound card to reach the memory slot. I almost given up at the keyboard stage actually (that’s when I realized the guide has 4 more pages).

I fixed in the RAM and put everything back and am glad it is all working fine. But it’s certainly a task not for the fainthearted.

I also fixed in more RAM in my desktop my Windows Vista and Windows 7 are both significantly quicker. Photoshop did launch slightly quicker. I don’t feel an improvement in the start up time though. As for the netbook, I have yet to feel much improvement actually.

Remember to clear your Apache logs

This is what happens if you don’t clear your Apache logs:

[code lang=”bash”]jr ~/ ls -al
total 205748
drwxr-s— 2 me www-data 4096 Aug 5 2008 .
drwxr-s— 8 me www-data 4096 Sep 9 14:58 ..
-rw-r–r– 1 root www-data 210250161 Feb 21 17:08 access.log
-rw-r–r– 1 root www-data 205822 Feb 21 15:49 error.log[/code]

That’s 210 MB of data I am least interested with. By the way I just realized delete the log actually lowers memory usage significantly.

256 MB probably isn’t enough for me

Keep getting this today. Looks like tweaking the MySQL and Apache processes didn’t really work. Things still go down. I had to do a hard reboot today:

Out of Memory: Kill process 4446 (mysqld) score 124676 and children.
Out of memory: Killed process 4446 (mysqld).
Out of Memory: Kill process 4712 (mysqld) score 53658 and children.
Out of memory: Killed process 4712 (mysqld).
Out of Memory: Kill process 4727 (mysqld) score 53658 and children.
Out of memory: Killed process 4727 (mysqld).
Out of Memory: Kill process 4728 (mysqld) score 53658 and children.
Out of memory: Killed process 4728 (mysqld).
Out of Memory: Kill process 4626 (apache2) score 41595 and children.
Out of memory: Killed process 4626 (apache2).
Out of Memory: Kill process 4613 (apache2) score 41570 and children.
Out of memory: Killed process 4613 (apache2).
Out of Memory: Kill process 4742 (mysqld) score 104640 and children.
Out of memory: Killed process 4742 (mysqld).
Out of Memory: Kill process 4812 (mysqld) score 70759 and children.
Out of memory: Killed process 4812 (mysqld).

This 256 MB VPS runs 2.5 blogs and 1 Python.

Well, it’s time to upgrade to 512 MB I guess. I was intending to up the lighttpd server but perhaps it shall stay asleep but another 2 months. I probably am upgrading to 512 MB coming January.

My kindergarten keeps feeding me with this

I wanted to buy a packet of these the other day just for old time’s sake but figured I only want to eat just a couple of it and probably throw the rest away.

My kindergarten always feeds me with this

What’s this biscuit called by the way?

I ate tons of it when I was in kindergarten and I remember there’s this girl who only eats the colored sugary top and protested to finish the biscuit.

When I’m feeling down…

I tend to chat with people in order to avoid thinking about the sadder events. It works sometimes, not really working that often already though.

I engaged myself in many conversations to try to forget certain events. But each time there is no reply from the other party, my mind drifted off and the sad events revisited.

Every early in the morning, my day begins clean, no sad memories come to me. At the end of the day, sad memories revisit me. And every night I sleep with this loss, this sadness. I toss and turn a little and fell asleep. You know, usually when you say good bye to someone online, you tell them to “sleep well”, or “good night” or whatever. Sometimes, I tell a friend something like, “hope you won’t toss and turn tonight, hahaa…”

Maybe… I would prefer to be told that.