from sys import getsizeof class A(object): pass class B: pass for x in (None, 1, 1L, 1.2, 'c', [], (), {}, set(), B, B(), A, A()): print "{0:20s}\t{1:d}".format(type(x).__name__, sys.getsizeof(x)) NoneType 16 int 24 long 28 float 24 str 34 list
修改/proc/sys/vm/drop_caches,释放Slab占用的cache内存空间(参考drop_caches的官方文档): Writing to this will cause the kernel to drop clean caches, dentries and inodes from memory, causing that memory to become free. To free pagecache: * echo 1 > /proc/sys/vm/drop_caches