top.1   [plain text]

.\" Copyright (c) 2002--2020 Apple Computer, Inc.  All rights reserved.
.\" The contents of this file constitute Original Code as defined in and
.\" are subject to the Apple Public Source License Version 1.1 (the
.\" "License").  You may not use this file except in compliance with the
.\" License.  Please obtain a copy of the License at
.\" and read it before using this file.
.\" This Original Code and all software distributed under the License are
.\" distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
.\" License for the specific language governing rights and limitations
.\" under the License.
.Dd February 10, 2020
.Dt TOP 1
.Os Darwin
.Nm top
.Nd display sorted information about processes
.Bl -tag -width "top " -compact
.It Nm Op Fl a | Fl d | Fl e | Fl c Ar mode
.Bl -item -offset "top " -compact
.Op Fl F | Fl f
.Op Fl h
.Op Fl i Ar interval
.Op Fl l Ar samples
.Op Fl ncols Ar columns
.Op Fl o Ar key | Fl O Ar skey
.Op Fl R | Fl r
.Op Fl S
.Op Fl s Ar delay-secs
.Op Fl n Ar nprocs
.Op Fl stats Ar keys
.Op Fl pid Ar processid
.Op Fl user Ar username
.Op Fl U Ar username
.Op Fl u
program periodically displays a sorted list of system processes.
The default sorting key is pid, but other keys can be used instead.
Various output options are available.
Command line option specifications are processed from left to right.
Options can be specified more than once.
If conflicting options are specified, later specifications override earlier
This makes it viable to create a shell alias for
with preferred defaults specified, then override those preferred defaults as
desired on the command line.
.Bl -tag -width indent
.It Fl a
Equivalent to
.Fl c Ar a .
.It Fl c Ar mode
Set event counting mode to
.Ar mode .
The supported modes are
.Bl -tag -width indent
.It a
Accumulative mode.
Count events cumulatively, starting at the launch of
.Nm .
Calculate CPU usage and CPU time since the launch of
.Nm .
.It d
Delta mode.
Count events relative to the previous sample.
Calculate CPU usage since the previous sample.
This mode by default disables the memory object map reporting.
The memory object map reporting may be re-enabled with the
.Fl r
option or the interactive
.Cm r
.It e
Absolute mode.
Count events using absolute counters.
.It n
Non-event mode
.Pq default .
Calculate CPU usage since the previous sample.
.It Fl d
Equivalent to
.Fl c Ar d .
.It Fl e
Equivalent to
.Fl c Ar e .
.It Fl F
Do not calculate statistics on shared libraries, also known as frameworks.
.It Fl f
Calculate statistics on shared libraries, also known as frameworks
.Pq default .
.It Fl h
Print command line usage information and exit.
.It Fl i Ar interval
Update framework
.Pq Fl f
info every
.Ar interval
samples; see the
section for more details.
.It Fl l Ar samples
Use logging mode and display
.Ar samples
samples, even if standard output is a terminal.
0 is treated as infinity.
Rather than redisplaying, output is periodically printed in raw form.
Note that the first sample displayed will have an invalid %CPU displayed for
each process, as it is calculated using the delta between samples.
.It Fl ncols Ar columns
.Ar columns
when using logging mode.
The default is infinite.
The number must be > 0 or an error will occur.
.It Fl n Ar nprocs
Only display up to
.Ar nprocs
.It Fl O Ar skey
.Ar skey
as a secondary key when ordering the process display.
.Fl o
for key names
.Pq Li pid is the default .
.It Fl o Ar key
Order the process display by sorting on
.Ar key
in descending order.
A + or - can be prefixed to the key name to specify ascending or descending
order, respectively.
The supported keys are:
.Bl -tag -width indent
.It pid
Process ID
.It command
Command name.
.It cpu
CPU usage.
.Pq default .
.It cpu_me
CPU time charged to me by other processes.
.It cpu_others
CPU time charged to other processes by me.
.It csw
The number of context switches.
.It time
Execution time.
.It threads
alias: th
Number of threads
.Pq total/running .
.It ports
alias: prt
Number of Mach ports.
.It mregion
alias: mreg, reg
Number of memory regions.
.It mem
Physical memory footprint of the process.
.It rprvt
Resident private address space size.
.It purg
Purgeable memory size.
.It vsize
Total memory size.
.It vprvt
Private address space size.
.It kprvt
Private kernel memory size.
.It kshrd
Shared kernel memory size.
.It pgrp
Process group ID.
.It ppid
Parent process ID.
.It state
alias: pstate
Process state.
One of "zombie", "running", "stuck" (i.e. uninterruptible sleep),  "sleeping", "idle", "stopped", "halted", or "unknown".
.It uid
User ID.
.It wq
alias: #wq, workqueue
The workqueue total/running.
.It faults
alias: fault
The number of page faults.
.It cow
alias: cow_faults
The copy-on-write faults.
.It user
alias: username
.It msgsent
Total number of Mach messages sent.
.It msgrecv
Total number of Mach messages received.
.It sysbsd
Total BSD syscalls.
.It sysmach
Total Mach syscalls.
.It pageins
Total pageins.
.It boosts
The number of boosts held by the process.
This is followed by the number of
times the process has transitioned from unboosted to boosted in brackets.
An asterisk before the value indicates that the process was able to send boosts
at some point since the previous update.
For more information about boosts, see
.Xr xpc_transaction_begin 3 .
.It instrs
The number of instructions retired by the process in both user space and the
.It cycles
The number of cycles spent executing instructions in the process in both user
space and the kernel.
.It Fl R
Do not traverse and report the memory object map for each process
.Pq default .
.It Fl r
Traverse and report the memory object map for each process.
.It Fl S
Display the global statistics for swap and purgeable memory.
.It Fl s Ar delay-secs
Set the delay between updates to
.Ar delay-secs
The default delay between updates is 1 second.
.It Fl stats Ar keys
Only display the comma separated statistics.
See the
.Fl o
flag for the valid
.Ar keys .
.It Fl pid Ar processid
Only display
.Ar processid
.Nm .
This option may be specified multiple times.
.It Fl user Ar user
Only display processes owned by
.Ar user
.It Fl U Ar user
This is an alias for
.Fl user .
.It Fl u
This is an alias equivalent to:
.Fl o Ar cpu Fl O Ar time
The first several lines of the
display show various global state.
All of the information is labeled.
Following is an alphabetical list of global state fields and their descriptions.
.Bl -tag -width "MemRegions"
Percentage of processor usage, broken into user, system, and idle components.
The time period for which these percentages are calculated depends on the event
counting mode.
.It Disks
Number and total size of disk reads and writes.
.It LoadAvg
Load average over 1, 5, and 15 minutes.
The load average is the average number of jobs in the run queue.
.It MemRegions
Number and total size of memory regions, and total size of memory regions broken
into private
.Pq broken into non-library and library
and shared components.
.It Networks
Number and total size of input and output network packets.
.It PhysMem
Physical memory usage, broken into wired, active, inactive, used, and free
.It Procs
Total number of processes and number of processes in each process state.
.It SharedLibs
Resident sizes of code and data segments, and link editor memory usage.
.It Threads
Number of threads.
.It Time
Time, in H:MM:SS format.
When running in logging mode, Time is in YYYY/MM/DD HH:MM:SS format by default,
but may be overridden with accumulative mode.
When running in accumulative event counting mode, the Time is in HH:MM:SS since
the beginning of the
.It VirtMem
Total virtual memory, virtual memory consumed by shared libraries, and number of
pageins and pageouts.
.It Swap
Swap usage: total size of swap areas, amount of swap space in use and amount of
swap space available.
.It Purgeable
Number of pages purged and number of pages currently purgeable.
Below the global state fields, a list of processes is displayed.
The fields that are displayed depend on the options that are set.
The pid field displays the following for the architecture:
+ for 64-bit native architecture, or - for 32-bit native architecture, or * for
a non-native architecture.
is run in interactive
.Pq non-logging
mode, it is possible to control the output of
.Nm ,
as well as interactively send signals to processes.
The interactive command syntax is terse.
Each command is one character, followed by 0 to 2 arguments.
Commands that take arguments prompt interactively for the arguments, and where
applicable, the default value is shown in square brackets.
The default value can be selected by leaving the input field blank and pressing
.Li ^G
escapes the interactive argument prompt, and has the same effect as leaving the
input field blank and pressing enter.
The following commands are supported:
.Bl -tag -width indent
.It ?
Display the help screen.
Any character exits help screen mode.
This command always works, even in the middle of a command.
.It ^L
Redraw the screen.
.It c Ns Ar mode
Set output mode to
.Ar mode .
See the
.Fl c
option for descriptions of the allowed modes.
.It O Ns Ar skey
.Ar skey
as a secondary key when ordering the process display.
See the
.Fl o
option for key names.
.It o Ns Ar key
Order the process display by sorting on
.Ar key
in descending order.
A + or - can be prefixed to the key name to specify ascending or descending
order, respectively.
The supported keys and alises are listed with the
.Fl o
option above.
.It q
.It r
Toggle traversal and reporting of the memory object map for each process.
.It S Ns Ar signal Ns Ar pid
Send signal
.Ar signal
.Ar pid .
.Ar signal
can be specified either as a number or as a name
.Pq for example, Li HUP .
The default signal starts out as
.Li TERM .
Each time a signal is successfully sent, the default signal is updated to be
that signal.
.Ar pid
is a process id.
.It s Ar delay-secs
Set the delay between updates to
.Ar delay-secs
.It U Ar user
Only display processes owned by
.Ar user.
Either the username or uid number can be specified.
To display all processes, press enter without entering a username or uid number.
Calculating detailed memory statistics is fundamentally resource-intensive.
To reduce the CPU usage in
.Nm ,
.Fl i
option has been introduced to allow the user to tune this tradeoff.
With the default value of 10, framework stats will be updated once every 10
.Fl i Ar 1
will result in the most accurate display, at the expense of system resources.
.Li N/A
occurs in a stat, it's caused by the memory object map reporting being disabled.
Memory object map reporting is disabled by default in delta mode, but may be
optionally enabled via
.Fl r
or the interactive
.Cm r
To enable the
.Fl r
option, use it after any
.Fl c
mode options.
.Bl -tag -width indent
.It top -o cpu -O +rsize -s 5 -n 20
Sort the processes according to CPU usage (descending) and resident memory size
(ascending), sample and update the display at 5 second intervals, and limit the
display to 20 processes.
.It top -c d
in delta mode.
.It top -stats pid,command,cpu,th,pstate,time
Display only the specified statistics, regardless of any growth of the terminal.
If the terminal is too small, only the statistics that fit will be displayed.
.Xr taskinfo 1 ,
.Xr vm_stat 1 ,
.Xr vmmap 1 ,
.Xr kill 2 ,
.Xr signal 3