Running install_prereq failed after several minutes

I took the instructions from asterisk.org documentation to run “install_prereq” script, it started outputting following messages:
opened: xxx closed: xxx defer: xxx conflict: xxx

After running several minutes, the number after “opened” is increased to 225031, then it stopped increasting. Now I found the system is very slow, and “aptitude” process is taking up 85% of system memory (my RAM size is 4G).
Then I went out and came back after half an hour, these numbers are still not changed and the UI is blocked (I typed a character, it will display on screen after 5 seconds)

I’m using Ubuntu 12.04