자바 같은 경우 프로세스가 두개 이상 구동될 수가 있어서 메모리가 줄어 들수 있다.
불필요한
캐쉬 메모리를 지워보자.
#sync && echo 3 > /proc/sys/vm/drop_caches
free -m
* 매일 새벽 4시에 캐시메모리를 비우는 방법.
#crontab -e
0 4 * * * sync && echo 3 > /proc/sys/vm/drop_caches
2 간단히 보기(ps -ef)[편집]
ps -ef --sort -rss
실행예시
[root@zetawiki ~]# ps -ef --sort -rss UID PID PPID C STIME TTY TIME CMD mysql 1154 1064 99 May03 ? 213287-12:54:30 /usr/libexec/mysqld --basedir=/usr --datadir=/var/lib/mysql --user=mysql --l apache 26245 1202 0 03:48 ? 00:00:05 /usr/sbin/httpd apache 26247 1202 0 03:48 ? 00:00:07 /usr/sbin/httpd ... (생략) root 741 2 0 May03 ? 00:00:00 [kmpath_handlerd] root 768 2 0 May03 ? 00:00:00 [kjournald]
→ /usr/libexec/mysqld 프로세스가 물리 메모리를 가장 많이 점유하고 있다.
2.1 상위 10개[편집]
명령어
ps -ef --sort -rss | head -n 11
3 메모리 사용량 표시 (ps -eo)[편집]
명령어
ps -eo user,pid,ppid,rss,size,vsize,pmem,pcpu,time,cmd --sort -rss | head -n 11
실행 예시
[root@zetawiki ~]# ps -eo user,pid,ppid,rss,size,vsize,pmem,pcpu,time,cmd --sort -rss | head -n 11 USER PID PPID RSS SZ VSZ %MEM %CPU TIME CMD mysql 1154 1064 26116 582252 642724 4.8 6623646 213287-12:54:31 /usr/libexec/mysqld --basedir=/usr --datadir=/var/lib/mysql --user=mysql --log-error=/var/log/mysqld.log --pid-file=/var/run/mysqld/mysqld.pid --socket=/var/lib/mysql/mysql.sock apache 26245 1202 24284 18320 347196 4.5 0.0 00:00:05 /usr/sbin/httpd apache 26247 1202 23780 17824 346700 4.4 0.0 00:00:07 /usr/sbin/httpd apache 26248 1202 23632 17048 345924 4.4 0.0 00:00:05 /usr/sbin/httpd apache 26242 1202 23112 18080 342768 4.3 0.0 00:00:06 /usr/sbin/httpd apache 26249 1202 23100 18076 342764 4.3 0.0 00:00:06 /usr/sbin/httpd apache 26692 1202 23084 18084 342772 4.3 0.0 00:00:03 /usr/sbin/httpd apache 26244 1202 22844 17828 342516 4.2 0.0 00:00:06 /usr/sbin/httpd apache 26243 1202 22832 17828 342516 4.2 0.0 00:00:08 /usr/sbin/httpd apache 26693 1202 22832 17820 342508 4.2 0.0 00:00:04 /usr/sbin/httpd
→ /usr/libexec/mysqld 프로세스가 물리 메모리를 가장 많이 점유하고 있으며 그 용량은 26116KB이다.
3.1 명령인수 숨기기[편집]
프로세스 수행명령어에서 인수부분을 표시하지 않으려면 cmd를 comm으로 변경하면 된다.
명령어
ps -eo user,pid,ppid,rss,size,vsize,pmem,pcpu,time,comm --sort -rss | head -n 11
실행 예시
[root@zetawiki ~]# ps -eo user,pid,ppid,rss,size,vsize,pmem,pcpu,time,comm --sort -rss | head -n 11 USER PID PPID RSS SZ VSZ %MEM %CPU TIME COMMAND mysql 1154 1064 26116 582252 642724 4.8 6624384 213287-12:54:31 mysqld apache 26245 1202 24284 18320 347196 4.5 0.0 00:00:05 httpd apache 26247 1202 23780 17824 346700 4.4 0.0 00:00:07 httpd apache 26248 1202 23632 17048 345924 4.4 0.0 00:00:05 httpd apache 26242 1202 23112 18080 342768 4.3 0.0 00:00:06 httpd apache 26249 1202 23100 18076 342764 4.3 0.0 00:00:06 httpd apache 26692 1202 23084 18084 342772 4.3 0.0 00:00:03 httpd apache 26244 1202 22844 17828 342516 4.2 0.0 00:00:06 httpd apache 26243 1202 22832 17828 342516 4.2 0.0 00:00:08 httpd apache 26693 1202 22832 17820 342508 4.2 0.0 00:00:04 httpd
EX)
[root@localhost ~]# ps -eo user,pid,ppid,rss,size,vsize,pmem,pcpu,time,comm --sort -rss | head -n 11
USER PID PPID RSS SZ VSZ %MEM %CPU TIME COMMAND
root 1643 1 196456 2047256 2202024 39.1 0.1 00:11:12 java
root 7112 1 192896 2046564 2201332 38.4 5.2 00:03:21 java
root 7460 901 1948 1224 102904 0.3 0.0 00:00:00 sshd
root 7462 7460 1276 552 108428 0.2 0.0 00:00:00 bash
root 7866 7462 1108 1200 110340 0.2 0.0 00:00:00 ps
root 901 1 848 604 66204 0.1 0.0 00:00:00 sshd
root 7867 7462 712 264 100980 0.1 0.0 00:00:00 head
root 872 1 660 227824 249088 0.1 0.0 00:00:00 rsyslogd
root 332 1 632 652 10900 0.1 0.0 00:00:03 udevd
root 1066 332 628 648 10896 0.1 0.0 00:00:00 udevd
불필요하게 자바가 2개가 구동중이다.
어떤것이 사용중인 확인
[root@localhost ~]# netstat -tnlp
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:21 0.0.0.0:* LISTEN 920/vsftpd
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 901/sshd
tcp 0 0 ::ffff:127.0.0.1:8080 :::* LISTEN 7112/java
tcp 0 0 :::80 :::* LISTEN 7112/java
tcp 0 0 :::22 :::* LISTEN 901/sshd
tcp 0 0 :::8009 :::* LISTEN 7112/java
[root@localhost ~]# kill -9 1643
[root@localhost ~]# free -m
total used free shared buffers cached
Mem: 490 251 239 0 4 23
-/+ buffers/cache: 223 267
Swap: 0 0 0
댓글 ( 6)
댓글 남기기