Firefox OS/Performance/Memory/ADB Tools
b2g-ps
The b2g-ps
command performs a simple process listing and filter out all non-b2g processes. While it does not provide too much memory information, it is usable on production devices where root
is not available.
The command provides:
-
RSS
: The combined, unique and shared, memory currently paged into the process as Resident Set Size. -
VSIZE
: The virtual address space referenced by the process. This will typically be larger than the actual memory in use.
bkelly@lenir:/srv/gaia-master$ adb shell b2g-ps
APPLICATION USER PID PPID VSIZE RSS WCHAN PC NAME
b2g root 292 1 183060 76256 ffffffff b6f0563c S /system/b2g/b2g
(Nuwa) root 815 292 53304 20988 ffffffff b6ea963c S /system/b2g/plugin-container
Homescreen u0_a958 958 815 72000 27420 ffffffff b6ea963c S /system/b2g/plugin-container
Communications u0_a1303 1303 815 73388 26864 ffffffff b6ea963c S /system/b2g/plugin-container
Marketplace u0_a1461 1461 815 89636 39760 ffffffff b6ea963c S /system/b2g/plugin-container
(Preallocated a u0_a1512 1512 815 60476 18360 ffffffff b6ea963c S /system/b2g/plugin-container
b2g-info
The b2g-info
command is available on devices flashed with an engineering build. It requires root
permissions to run. It provides more detailed information than b2g-ps
and also provides data on overall system resources.
Specifically, for each process b2g-info
provides:
-
USS
: The memory unique to the process as Unique Set Size. -
PSS
: Memory shared with other processes as Proportional Set Size. -
RSS
: The combined, unique and shared, memory currently paged into the process as Resident Set Size. -
VSIZE
: The virtual address space referenced by the process. This will typically be larger than the actual memory in use.
For the overall system b2g-info
provides:
-
Free
: Free memory not currently in use by any process. -
Cache
: Memory currently holding files paged into a process. These can typically be flushed back to disk to increaseFree
memory. Of course, the running application will always need some part of its executable and library paged in, so this will never go to zero. -
Free+Cache
: The effective total amount of memory the system considers "available" for new processes.
Finally, b2g-info
provides some information about the thresholds at which it will attempt to kill processes. When Free+Cache
(or is it Free
?) reaches the given min_free
value then processes with the given calculated oom_adj
score will be killed.
bkelly@lenir:/srv/gaia-master$ adb shell b2g-info
| megabytes |
NAME PID PPID CPU(s) NICE USS PSS RSS VSIZE OOM_ADJ USER
b2g 292 1 75.5 0 57.7 63.1 76.7 178.8 0 root
(Nuwa) 815 292 1.4 0 3.7 8.0 20.5 52.1 0 root
Homescreen 958 815 5.5 18 11.1 14.4 27.4 70.3 8 u0_a958
Communications 1303 815 2.5 18 10.6 13.9 26.9 71.7 10 u0_a1303
Marketplace 1461 815 198.4 1 22.7 26.4 40.1 87.5 2 u0_a1461
(Preallocated a 1512 815 0.6 18 5.2 7.6 18.2 59.1 10 u0_a1512
System memory info:
Total 410.6 MB
Used - cache 181.1 MB
B2G procs (PSS) 133.5 MB
Non-B2G procs 47.7 MB
Free + cache 229.4 MB
Free 96.7 MB
Cache 132.7 MB
Low-memory killer parameters:
notify_trigger 14336 KB
oom_adj min_free
0 4096 KB
58 5120 KB
117 6144 KB
352 7168 KB
470 8192 KB
588 20480 KB
/proc/meminfo
The linux proc filesystem provides additional information about system memory resources at /proc/meminfo
. This can be useful if you want to breakdown system memory in a different way than b2g-info
.
There is a lot of information available in /proc/meminfo
. For a description of the various fields please see the proc(5) man page.
bkelly@lenir:/srv/gaia-master$ adb shell cat /proc/meminfo
MemTotal: 420412 kB
MemFree: 56936 kB
Buffers: 16796 kB
Cached: 136632 kB
SwapCached: 0 kB
Active: 159568 kB
Inactive: 131732 kB
Active(anon): 137884 kB
Inactive(anon): 8492 kB
Active(file): 21684 kB
Inactive(file): 123240 kB
Unevictable: 0 kB
Mlocked: 0 kB
SwapTotal: 196604 kB
SwapFree: 196604 kB
Dirty: 4 kB
Writeback: 0 kB
AnonPages: 137900 kB
Mapped: 48292 kB
Shmem: 8528 kB
Slab: 22008 kB
SReclaimable: 8664 kB
SUnreclaim: 13344 kB
KernelStack: 3056 kB
PageTables: 2280 kB
NFS_Unstable: 0 kB
Bounce: 0 kB
WritebackTmp: 0 kB
CommitLimit: 406808 kB
Committed_AS: 248120 kB
VmallocTotal: 499712 kB
VmallocUsed: 3396 kB
VmallocChunk: 409764 kB
/sys/kernel/debug/ion/iommu
Starting in Android in Jelly Bean (JB) the system now uses the ion memory allocator for graphics shared buffers. Due to the complexity of the graphics system this can often be a source for resource exhaustion or other problems.
On some devices the kernel provides debug information about ion memory use at /sys/kernel/debug/ion/iommu
.
Note, on Firefox OS this will report allocations still in use as "orphaned" when they are actually not really leaked. It seems this is related to our multi-process architecture.
bkelly@lenir:/srv/gaia-master$ adb shell cat /sys/kernel/debug/ion/iommu
client pid size
----------------------------------------------------
adsprpc-smd 1 8192
----------------------------------------------------
orphaned allocations (info is from last known client):
Browser 1758 294912 0 1
Marketplace 1461 294912 0 1
Browser 1758 294912 0 1
Browser 1758 294912 0 1
Browser 1758 294912 0 1
Browser 1758 294912 0 1
Browser 1758 294912 0 1
Browser 1758 294912 0 1
Browser 1758 294912 0 1
Browser 1758 294912 0 1
Browser 1758 294912 0 1
Browser 1758 294912 0 1
Browser 1758 294912 0 1
Browser 1758 294912 0 1
b2g 292 4096 0 1
Browser 1758 294912 0 1
Marketplace 1461 294912 0 1
Marketplace 1461 294912 0 1
Marketplace 1461 294912 0 1
Marketplace 1461 294912 0 1
Browser 1758 294912 0 1
b2g 292 4096 0 1
b2g 292 4096 0 1
Browser 1758 294912 0 1
Marketplace 1461 294912 0 1
Browser 1758 294912 0 1
Browser 1758 294912 0 1
Marketplace 1461 294912 0 1
Marketplace 1461 294912 0 1
Marketplace 1461 4096 0 1
b2g 292 1536000 0 1
b2g 292 1536000 0 1
Marketplace 1461 16384 0 1
mdss_fb0 350 1536000 0 1
b2g 292 1536000 0 1
Marketplace 1461 16384 0 1
Marketplace 1461 16384 0 1
Marketplace 1461 16384 0 1
Marketplace 1461 16384 0 1
Communications 1303 294912 0 1
Communications 1303 294912 0 1
----------------------------------------------------
total orphaned 14499840
total 14508032
----------------------------------------------------
Cached Pools:
0 order 9 highmem pages in pool = 0 total
0 order 9 lowmem pages in pool = 0 total
0 order 8 highmem pages in pool = 0 total
0 order 8 lowmem pages in pool = 0 total
0 order 4 highmem pages in pool = 0 total
0 order 4 lowmem pages in pool = 0 total
0 order 0 highmem pages in pool = 0 total
3810 order 0 lowmem pages in pool = ee2000 total
Uncached Pools:
0 order 9 highmem pages in pool = 0 total
0 order 9 lowmem pages in pool = 0 total
0 order 8 highmem pages in pool = 0 total
0 order 8 lowmem pages in pool = 0 total
0 order 4 highmem pages in pool = 0 total
0 order 4 lowmem pages in pool = 0 total
0 order 0 highmem pages in pool = 0 total
0 order 0 lowmem pages in pool = 0 total
Total bytes in pool: ee2000