缓存的内存一直增长到oom killer激活为止/如何分析缓存的内存?

时间:2018-07-31 16:44:31

标签: linux linux-kernel

在Linux框中,我们启动一个Java应用程序并使用宏与GUI进行交互。 1小时后,所有缓存的内存已满,无法释放! oom Killer激活并杀死Java应用程序。

$uname -a
Linux glp-56-summe 3.18.21-rt19 #27 SMP PREEMPT RT Wed Aug 10 16:22:37 CEST 2016 i686 GNU/Linux
$cat /etc/debian_version 
8.3

1小时后:

$ free -m;echo 3>/proc/sys/vm/drop_caches;free -m
             total       used       free     shared    buffers     cached
Mem:           742        734          8        294         67        385
-/+ buffers/cache:        280        461
Swap:            0          0          0

             total       used       free     shared    buffers     cached 
Mem:           742        734          8        294         67        385
-/+ buffers/cache:        280        461 
Swap:            0          0          0

不可能释放缓存的内存!

$ top
top - 18:23:46 up 1 day,  3:50,  1 user,  load average: 4.40, 4.04, 3.75
Tasks: 119 total,   2 running, 117 sleeping,   0 stopped,   0 zombie
%Cpu(s): 52.0 us, 34.2 sy,  1.6 ni,  0.0 id,  3.6 wa,  3.6 hi,  4.9 si,  0.0 st
KiB Mem:    760016 total,   751904 used,     8112 free,    70856 buffers
KiB Swap:        0 total,        0 used,        0 free.   393176 cached Mem

  PID USER      PR  NI    VIRT    RES    SHR S %CPU %MEM     TIME+ COMMAND                                                                                                  
 1497 user1     20   0  340064 187740  31588 S 58.6 24.7  31:45.31 java                                                                                                     
 1998 root      21   1   30488    144      0 S 10.1  0.0  16:30.54 tracelogd                                                                                                
 2095 root      19  -1  282328  19588  11704 S  6.2  2.6  15:36.66 Xorg                                                                                                     
 2295 root      20   0  761900  29460      0 S  5.6  3.9  79:17.51 glp3_linux_utf8                                                                                          
 1755 user1     20   0   35180  10844   9324 S  1.3  1.4   0:23.77 scim-panel-gtk                                                                                           
 1747 user1     20   0   15108  10224   3136 S  1.0  1.3   0:20.87 scim-launcher                                                                                            
    3 root      -2   0       0      0      0 S  0.7  0.0   8:09.52 ksoftirqd/0     

$ df –h
Filesystem                             Size  Used Avail Use% Mounted on
/dev/root                              3.6G  1.8G  1.7G  52% /
devtmpfs                               371M     0  371M   0% /dev
tmpfs                                   75M  664K   74M   1% /run
tmpfs                                  5.0M     0  5.0M   0% /run/lock
tmpfs                                  149M   36K  149M   1% /run/shm

也没有使用缓存的tmpfs

$ ls -all /dev/shm/
total 36
drwxrwxrwt  2 root root       160 Jul 31 15:23 .
drwxr-xr-x 13 root root       600 Jul 30 14:33 ..
-rw-r--r--  1 root root         0 Jul 30 14:32 .tmpfs
-rwxrwxrwx  1 root bizgroup 79400 Jul 30 14:33 BMQforGXNET_SHM
-rwxrwxrwx  1 root bizgroup    16 Jul 30 14:33 sem.BMQforGXNET
-rw-r--r--  1 root root        16 Jul 31 15:23 sem.SemQuEdvSnd
-rw-r--r--  1 root root        16 Jul 31 15:23 sem.SemQuRcv
-rw-r--r--  1 root bizgroup    16 Jul 30 14:33 sem.glp3_linux_utf8.wdogsema

$ cat /proc/meminfo
cat /proc/meminfo 
MemTotal:         760016 kB
MemFree:            8724 kB
MemAvailable:     172644 kB
Buffers:           70024 kB
Cached:           393636 kB
SwapCached:            0 kB
Active:           318060 kB
Inactive:         379372 kB
Active(anon):     235340 kB
Inactive(anon):   297964 kB
Active(file):      82720 kB
Inactive(file):    81408 kB
Unevictable:           8 kB
Mlocked:               0 kB
HighTotal:             0 kB
HighFree:              0 kB
LowTotal:         760016 kB
LowFree:            8724 kB
SwapTotal:             0 kB
SwapFree:              0 kB
Dirty:              1516 kB
Writeback:             0 kB
AnonPages:        233808 kB
Mapped:            58348 kB
Shmem:            299520 kB
Slab:              23212 kB
SReclaimable:      13220 kB
SUnreclaim:         9992 kB
KernelStack:        2896 kB
PageTables:         1912 kB
NFS_Unstable:          0 kB
Bounce:                0 kB
WritebackTmp:          0 kB
CommitLimit:     1520032 kB
Committed_AS:    1356900 kB
VmallocTotal:     241656 kB
VmallocUsed:        7384 kB
VmallocChunk:     224856 kB
HardwareCorrupted:     0 kB
HugePages_Total:       0
HugePages_Free:        0
HugePages_Rsvd:        0
HugePages_Surp:        0
Hugepagesize:       4096 kB
DirectMap4k:       35840 kB
DirectMap4M:      749568 kB



$cat /sys/kernel/debug/dri/0/i915_gem_objects
Xorg: 484 objects, 218091520 bytes (0 active, 211959808 inactive, 211959808 global, 1921024 shared, 1757184 unbound)

对象字节增长,达到440MB!

如何分析哪个进程/消耗了缓存的内存?

0 个答案:

没有答案