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