FortiGate
FortiGate Next Generation Firewall utilizes purpose-built security processors and threat intelligence security services from FortiGuard labs to deliver top-rated protection and high performance, including encrypted traffic.
npaiva
Staff
Staff
Article Id 349165
Description

 

This article describes why there is a difference in process memory usage between the following commands:

 

diag sys top-mem

diag sys top

 

Example:

 

FortiHome (global) # diagnose sys top 1
Run Time: 24 days, 18 hours and 34 minutes
0U, 0N, 0S, 100I, 0WA, 0HI, 0SI, 0ST; 1911T, 439F
forticron 200 S 0.4 2.0 0
snmpd 222 S 0.4 0.6 5
ipsengine 449 S < 0.0 4.3 5
ipsengine 450 S < 0.0 4.3 6
ipsengine 451 S < 0.0 4.2 7
node 212 S 0.0 3.7 2
cmdbsvr 151 S 0.0 2.7 0
ipshelper 207 S < 0.0 2.6 0
wad 292 S 0.0 2.4 2
cw_acd 249 S 0.0 1.9 1
scanunitd 216 S < 0.0 1.9 7
miglogd 210 S 0.0 1.8 4
reportd 211 S 0.0 1.7 3
forticldd 201 S 0.0 1.3 3
miglogd 386 S 0.0 1.3 3
csfd 269 S 0.0 1.3 5
fgfmd 248 S 0.0 1.2 6
httpsd 193 S 0.0 1.2 1
dnsproxy 263 S 0.0 1.1 0
newcli 17671 S 0.0 1.1 1

 

FortiHome (global) # diag sys top-mem
node (212): 74713kB
ipsengine (449): 53110kB
ipsengine (450): 52333kB
ipsengine (451): 50907kB
ipshelper (207): 31483kB
Top-5 memory used: 262546kB

 

Scope

 

FortiOS.

 

Solution

 

It is possible to observe that the results do not match between both commands.

The reason is that the number shown in 'top' is based on RSS (resident set size), while the number shown in 'top-mem' is based on PSS (proportional set size).


The main difference is how shared memory is calculated. For RSS, the size of shared memory is added to each process. For PSS, the size
of shared memory is split among the processes.

 

Example:

 

Process A has 50 KiB of unshared memory.
Process B has 300 KiB of unshared memory.

Both process A and process B have 100 KiB of the same shared memory region.

RSS of process A = 50 KiB + 100 KiB = 150 KiB.
RSS of process B = 300 KiB + 100 KiB = 400 KiB.

PSS of process A = 50 KiB + (100 KiB / 2) = 100 KiB.
PSS of process B = 300 KiB + (100 KiB / 2) = 350 KiB.