1e41f4b71Sopenharmony_ci# oom
2e41f4b71Sopenharmony_ci
3e41f4b71Sopenharmony_ci
4e41f4b71Sopenharmony_ci## 命令功能
5e41f4b71Sopenharmony_ci
6e41f4b71Sopenharmony_ci查看和设置低内存阈值以及pagecache内存回收阈值。
7e41f4b71Sopenharmony_ci
8e41f4b71Sopenharmony_ci
9e41f4b71Sopenharmony_ci## 命令格式
10e41f4b71Sopenharmony_ci
11e41f4b71Sopenharmony_cioom
12e41f4b71Sopenharmony_ci
13e41f4b71Sopenharmony_cioom -i [_interval_]
14e41f4b71Sopenharmony_ci
15e41f4b71Sopenharmony_cioom -m [_mem byte_]
16e41f4b71Sopenharmony_ci
17e41f4b71Sopenharmony_cioom -r [_mem byte_]
18e41f4b71Sopenharmony_ci
19e41f4b71Sopenharmony_cioom -h | --help
20e41f4b71Sopenharmony_ci
21e41f4b71Sopenharmony_ci
22e41f4b71Sopenharmony_ci## 参数说明
23e41f4b71Sopenharmony_ci
24e41f4b71Sopenharmony_ci**表1** 参数说明
25e41f4b71Sopenharmony_ci
26e41f4b71Sopenharmony_ci| 参数                    | 参数说明                        | 取值范围                                                     |
27e41f4b71Sopenharmony_ci| ----------------------- | ------------------------------- | ------------------------------------------------------------ |
28e41f4b71Sopenharmony_ci| -i [interval]      | 设置oom线程任务检查的时间间隔。 | [100, 10000] 单位: ms                                    |
29e41f4b71Sopenharmony_ci| -m [mem byte] | 设置低内存阈值。                | 0MB ~ 1MB,0MB表示不做低内存阈值检查。             |
30e41f4b71Sopenharmony_ci| -r [mem byte] | 设置pagecache内存回收阈值。     | 低内存阈值 ~ 系统可用最大内存,一个pagecache页一般为4KB,也有16 ~ 64KB的情况。 |
31e41f4b71Sopenharmony_ci| -h \| --help  | 使用帮助。                      | N/A                                                          |
32e41f4b71Sopenharmony_ci
33e41f4b71Sopenharmony_ci
34e41f4b71Sopenharmony_ci## 使用指南
35e41f4b71Sopenharmony_ci
36e41f4b71Sopenharmony_ci  参数缺省时,显示oom功能当前配置信息。
37e41f4b71Sopenharmony_ci
38e41f4b71Sopenharmony_ci> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:**
39e41f4b71Sopenharmony_ci> 当系统内存不足时,会打印出内存不足的提示信息。
40e41f4b71Sopenharmony_ci
41e41f4b71Sopenharmony_ci
42e41f4b71Sopenharmony_ci## 使用实例
43e41f4b71Sopenharmony_ci
44e41f4b71Sopenharmony_ci举例:
45e41f4b71Sopenharmony_ci
46e41f4b71Sopenharmony_ci- oom
47e41f4b71Sopenharmony_ci
48e41f4b71Sopenharmony_ci- oom -i 100
49e41f4b71Sopenharmony_ci
50e41f4b71Sopenharmony_ci
51e41f4b71Sopenharmony_ci## 输出说明
52e41f4b71Sopenharmony_ci
53e41f4b71Sopenharmony_ci**示例1** oom缺省打印配置信息
54e41f4b71Sopenharmony_ci
55e41f4b71Sopenharmony_ci
56e41f4b71Sopenharmony_ci```
57e41f4b71Sopenharmony_ciOHOS:/$ oom
58e41f4b71Sopenharmony_ci[oom] oom loop task status: enabled
59e41f4b71Sopenharmony_ci      oom low memory threshold: 0x80000(byte)
60e41f4b71Sopenharmony_ci      oom reclaim memory threshold: 0x500000(byte)
61e41f4b71Sopenharmony_ci      oom check interval: 100(microsecond)
62e41f4b71Sopenharmony_ci```
63e41f4b71Sopenharmony_ci
64e41f4b71Sopenharmony_ci系统内存不足时打印提示信息
65e41f4b71Sopenharmony_ci
66e41f4b71Sopenharmony_ci
67e41f4b71Sopenharmony_ci```
68e41f4b71Sopenharmony_ciT:20 Enter:IT MEM 00M 001
69e41f4b71Sopenharmony_ci[oom] OS is in low memory state
70e41f4b71Sopenharmony_citotal physical memory: 0x1bcf000(byte), used: 0x1b50000(byte) ,free: 0x7f000(byte), low memory threshold: 0x80000(byte)
71e41f4b71Sopenharmony_ci[oom] candidate victim process init pid: 1, actual phy mem byte:82602
72e41f4b71Sopenharmony_ci[oom] candidate victim process shell pid: 3, actual phy mem byte:14950e
73e41f4b71Sopenharmony_ci[oom] candidate victim process testsuits app pid: 4, actual phy mem byte:1334598
74e41f4b71Sopenharmony_ci[oom] candidate victim process UserProcess12 pid: 12, actual phy mem byte:25951558
75e41f4b71Sopenharmony_ci[oom] max phy mem used process UserProcess12 pid: 12, actual phy mem 25951558
76e41f4b71Sopenharmony_ci################excFrom: User!####################
77e41f4b71Sopenharmony_cidata abort fsr:0x817, far:0x225af000
78e41f4b71Sopenharmony_ciAbort caused by a write instruction. Translation fault, page
79e41f4b71Sopenharmony_ciexcType: data abort
80e41f4b71Sopenharmony_ciprocessName    = UserProcess12
81e41f4b71Sopenharmony_ciprocessID      = 12
82e41f4b71Sopenharmony_ciprocess aspace = 0х01000000 -> 0х3f000000
83e41f4b71Sopenharmony_citaskName       = threado
84e41f4b71Sopenharmony_citaskID         = 22
85e41f4b71Sopenharmony_citask user stack = 0х20e17000 -> 0х20e21000
86e41f4b71Sopenharmony_cipc   = 0x93969dc in /usr/bin/testsuits app ---> 0x19f9dc
87e41f4b71Sopenharmony_ciulr  = 0x93969cc in /usr/bin/testsuits app ---> 0x19f9cc
88e41f4b71Sopenharmony_ciusp  = 0х20e20c68fp = 0x20e20c8c
89e41f4b71Sopenharmony_ciR0   = 0х20e35000
90e41f4b71Sopenharmony_ciR1   = 0x225af000
91e41f4b71Sopenharmony_ciR2   = 0x0
92e41f4b71Sopenharmony_ciR3   = 0х28e35000
93e41f4b71Sopenharmony_ciR4   = 0х0
94e41f4b71Sopenharmony_ciR5   = 0х9500000
95e41f4b71Sopenharmony_ciR6   = 0х14
96e41f4b71Sopenharmony_ciR7   = 0х97822c4
97e41f4b71Sopenharmony_ciR8   = 0x970cfa8
98e41f4b71Sopenharmony_ciR9   = 0x9090909
99e41f4b71Sopenharmony_ciR10  = 0xa0a0a0a
100e41f4b71Sopenharmony_ciR11  = 0x20e20c8c
101e41f4b71Sopenharmony_ciR12  = 0х0
102e41f4b71Sopenharmony_ciCPSR = 0х80000010
103e41f4b71Sopenharmony_ci***backtrace beain***
104e41f4b71Sopenharmony_citraceback 0 -- lr = 0x9242e1c fp = 0х20e20cc4 lr in /usr/bin/testsuits apr 0x4be1c
105e41f4b71Sopenharmony_citraceback 1 -- 1r = 0х92430cc fp = 0x20e20cdc lr in /usr/bin/testsuits app --> 0x4c0cc
106e41f4b71Sopenharmony_citraceback 2 -- 1r = 0x9396ab0 fp = 0x20e20cec lr in /usr/bin/testsuits app -> 0х19fab0
107e41f4b71Sopenharmony_citraceback 3 -- lr = 0x9393eb4 fp = 0x20e20cf4 lr in /usr/bin/testsuits ap --> 0x19ceb4
108e41f4b71Sopenharmony_citraceback 4 -- lr = 0x92427d4 fp = 0x20e20d44 lr in /usr/bin/testsuits app --> 0x4b7d4
109e41f4b71Sopenharmony_citraceback 5 -- 1r = 0x20c4df50 fp = 0хb0b0b0b 1r in /1ib/libc.so - -> 0x62f50
110e41f4b71Sopenharmony_ci```
111e41f4b71Sopenharmony_ci
112e41f4b71Sopenharmony_ci
113e41f4b71Sopenharmony_ci**示例2** 设置 oom 线程任务检查的时间间隔
114e41f4b71Sopenharmony_ci
115e41f4b71Sopenharmony_ci
116e41f4b71Sopenharmony_ci
117e41f4b71Sopenharmony_ci```
118e41f4b71Sopenharmony_ciOHOS:/$ oom -i 100
119e41f4b71Sopenharmony_ci[oom] set oom check interval (100)ms successful
120e41f4b71Sopenharmony_ci```
121e41f4b71Sopenharmony_ci
122e41f4b71Sopenharmony_ci
123e41f4b71Sopenharmony_ci**表2** 输出说明
124e41f4b71Sopenharmony_ci
125e41f4b71Sopenharmony_ci| 输出                                                         | 说明                                                         |
126e41f4b71Sopenharmony_ci| ------------------------------------------------------------ | ------------------------------------------------------------ |
127e41f4b71Sopenharmony_ci| [oom]&nbsp;OS&nbsp;is&nbsp;in&nbsp;low&nbsp;memory&nbsp;state<br/>total&nbsp;physical&nbsp;memory:&nbsp;0x1bcf000(byte),&nbsp;used:&nbsp;0x1b50000(byte),&nbsp;free:&nbsp;0x7f000(byte),&nbsp;low&nbsp;memory&nbsp;threshold:&nbsp;0x80000(byte) | 操作系统处于低内存状态。<br/>整个系统可用物理内存为0x1bcf000&nbsp;byte,已经使用了&nbsp;0x1b50000&nbsp;byte,&nbsp;还剩0x7f000&nbsp;byte,当前设置的低内存阈值为0x80000&nbsp;byte。 |
128e41f4b71Sopenharmony_ci| [oom]&nbsp;candidate&nbsp;victim&nbsp;process&nbsp;init&nbsp;pid:&nbsp;1,&nbsp;actual&nbsp;phy&nbsp;mem&nbsp;byte:&nbsp;82602 | 打印当前各个进程的内存使用情况,init进程实际占用物理内存82602byte。 |
129e41f4b71Sopenharmony_ci| [oom]&nbsp;candidate&nbsp;victim&nbsp;process&nbsp;UserProcess12&nbsp;pid:&nbsp;12,&nbsp;actual&nbsp;phy&nbsp;mem&nbsp;byte:&nbsp;25951558 | UserProcess12进程实际使用25951558byte内存。                  |
130e41f4b71Sopenharmony_ci| [oom]&nbsp;max&nbsp;phy&nbsp;mem&nbsp;used&nbsp;process&nbsp;UserProcess12&nbsp;pid:&nbsp;12,&nbsp;actual&nbsp;phy&nbsp;mem:&nbsp;25951558 | 当前使用内存最多的进程是UserProcess12。                      |
131e41f4b71Sopenharmony_ci| excFrom:&nbsp;User!                                          | 当系统处于低内存的情况下,UserProcess12进程再去申请内存时失败退出。 |