blob: df9a7507200976a81d6d1aaad05d9446d098866a [file] [log] [blame]
#!/bin/bash
# Copyright 2021 The Fuchsia Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
#### CATEGORY=Diagnostic
### invoke mem tool on target device
##
## Usage: mem [options]
## Prints system-wide task and memory
##
## Memory numbers are triplets P,S,T
## P: Private bytes
## S: Total bytes scaled by 1/# processes sharing each byte
## T: Total bytes
## S and T are inclusive of P
##
## Options:
## [default] Human readable representation of process and vmo groups
## --trace Enable tracing support
## --print Machine readable representation of proccess and vmos
## --output CSV of process memory
## --repeat=N Runs forever, outputing every N seconds
## --pid=N Output vmo groups of process pid instead
## --digest Prints a bucketized digest of memory usage
## --signal=L Signal userspace clients with memory pressure level L
## where L can be CRITICAL, WARNING or NORMAL. Clients can
## use this command to test their response to memory pressure.
## Does not affect the real memory pressure level on the system,
## or trigger any kernel memory reclamation tasks.
source "$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)"/lib/vars.sh || exit $?
fx-config-read
case $1 in
-h|--help)
fx-command-help
exit 0
;;
esac
# TODO(fxbug.dev/82782): Support stdout/stderr in ffx component run
# If/when the bug above is fixed, uncomment the line below with `run` and delete
# the line below it with `run-legacy`.
# fx-command-run ffx component run fuchsia-pkg://fuchsia.com/mem#meta/mem.cm -- "$@"
fx-command-run ffx component run-legacy fuchsia-pkg://fuchsia.com/mem#meta/mem.cmx -- "$@"