Today, I checked the memory usage of the development server with spot on light, and only 60MB was left.
First, use free -m to check the remaining memory.
total used free shared buffers cached
Mem: 3383 3319 63 0 97 2395
-/+ buffers/cache: 826 2556
Swap: 1983 195 1788
total: Total memory used: Memory currently in use free: Unused memory shared: Total memory shared by multiple processes
Note: It’s best to run sync before releasing memory to prevent data loss.
Usage: sync
Description: In Linux, data intended for writing to the hard disk is sometimes, for efficiency,
written to the filesystem buffer. This buffer is a memory space.
If the data to be written to the disk resides in this buffer and the system suddenly loses power,
that data will be lost. The sync command forces the data in the buffer to be written to the hard disk.
[root@oracle ~]# echo 1 > /proc/sys/vm/drop_caches
[root@oracle ~]# sysctl -p
total used free shared buffers cached
Mem: 3383 1952 1431 0 1 1136
-/+ buffers/cache: 814 2568
Swap: 1983 195 1788
1>. /proc is a virtual filesystem; we can use read/write operations on it as a means to communicate with the kernel entity. That is, by modifying files within /proc, we can adjust the current kernel’s behavior. In this case, we can release memory by adjusting /proc/sys/vm/drop_caches.
1 – Release page cache
2 – Release dentries and inodes
3 – Release all caches
To free pagecache, use echo 1 > /proc/sys/vm/drop_caches;
to free dentries and inodes, use echo 2 > /proc/sys/vm/drop_caches;
to free pagecache, dentries and inodes, use echo 3 >/proc/sys/vm/drop_caches.
Because this is a non-destructive operation and dirty objects are not freeable, the user should run sync first.
Directory entry cache(dcache)dentries
total: Total physical memory
used: Memory currently in use
free: Memory completely unused
shared: Memory shared by applications
buffers: Cache, mainly used for directories, inode values, etc.
cached: Cache for opened files
-buffers/cache: Memory size used by applications, calculated as used minus cache values
+buffers/cache: Total memory size available for applications, calculated as free plus cache values
total = used + free
-buffers/cache=used-buffers-cached, which is the actual memory size used by applications
+buffers/cache=free+buffers+cached, which is the actual memory size the server can still utilize
total used free shared buffers cached
Mem: 32096 10379 21717 0 38 7942
-/+ buffers/cache: 2398 29698
Swap: 34287 0 34287
The second line here represents the actual free memory of the server.
echo 1 > /proc/sys/vm/drop_caches can temporarily clear cache and buffer
On RHEL5 and Ubuntu (not on RHEL4), you can directly modify the kernel file
# /etc/sysctl.conf
vm.drop_caches = 1
#sysctl -p
$ sync
$ free -m
total used free shared buffers cached
Mem: 32096 30084 2011 0 590 26162
-/+ buffers/cache: 3332 28764
Swap: 34287 0 34287
echo 3 > /proc/sys/vm/drop_caches
free -m
Method 1: arp -n|awk '/^[1-9]/ {print "arp -d "$1}' | sh
Clears all ARP cache, recommended!
Method 2: for((ip=2;ip<255;ip++));do arp -d 192.168.0.$ip &>/dev/null;done
Clears all cache for the 192.168.0.0 network segment.
Method 3: arp -d IP
This clears the ARP cache for a single IP.