리눅스에서는 최근 사용한 것들을 버리지 않고, 메모리에 cache 시켜 놓고 대기하는데 디스크에서 읽어 오는 것보다, 캐시된 메모리에서 읽어오는 것이 훨씬 빠르고, 디스크에 부하도 적게 걸리기 때문입니다.
따라서 시스템에서 알아서 관리해주는 것이 이전에 실행했던 것들을 비우지 않고 cache 해놓고 대기하고 있는 것입니다.
memory 에 적재되 있던 cache 강제로 flush
echo 3 > /proc/sys/vm/drop_caches
현재 메모리 사용량
클리어 이후 현재 메모리 사용량
메모리사용량 MRTG 수치
커널상에서 캐쉬를 클리어하게 만드는 값으로 1,2,3 중에 하나를 사용하면 된며 커널 2.6.16 이상에서부터 추가되서 사용가능하다.
To free pagecache: (페이지케쉬 클리어)
- echo 1 > /proc/sys/vm/drop_caches
To free dentries and inodes: (트리와 아이노드 클리어)
- echo 2 > /proc/sys/vm/drop_caches
To free pagecache, dentries and inodes: (1번과 2번 모두 클리어)
- echo 3 > /proc/sys/vm/drop_caches
As this is a non-destructive operation, and dirty objects are not freeable, the user should run "sync" first in order to make sure all cached objects are freed.