... | ... | @@ -48,9 +48,13 @@ Measuring real memory usage can be tricky, but fortunately, there are some tools |
|
|
|
|
|
### Measuring Memory Internally - BIND's view of memory usage
|
|
|
|
|
|
The BIND [statistics channel](https://bind9.readthedocs.io/en/latest/reference.html#namedconf-statement-statistics-channels) exposes counters for individual memory contexts. The important values are 'InUse' and `Malloced`. The `InUse` counter shows the memory actively used by BIND and `Malloced` includes the memory management overhead. Values reported by the operating system should be close to `Malloced` values.
|
|
|
The BIND [statistics channel](https://bind9.readthedocs.io/en/latest/reference.html#namedconf-statement-statistics-channels) exposes counters for individual memory contexts. The important values are 'InUse' and `Malloced`.
|
|
|
- `InUse` counter shows the memory actively used by BIND,
|
|
|
- `Malloced` includes the memory management overhead.
|
|
|
|
|
|
To summarize BIND's view of memory use, use script [memory-json.py](uploads/d907c0f06b7d36469443019920bf4b05/memory-json.py). The script parses the statistics channel output from URL `<bind>/json/v1` and produces summaries. In case BIND was compiled only with XML output support, take statistics from URL `<bind>/xml/v3` and convert it to JSON using [xq command](https://kislyuk.github.io/yq/#xml-support):
|
|
|
Memory usage as seen by the operating system should be close to sum of all 'Malloced' values.
|
|
|
|
|
|
To summarize BIND's view of memory use, use script [memory-json.py](uploads/d907c0f06b7d36469443019920bf4b05/memory-json.py). The script parses the statistics channel output from URL `<bind>/json/v1` and produces summaries. In case BIND was compiled only with XML statistics output take statistics from URL `<bind>/xml/v3` and convert them to JSON using [xq command](https://kislyuk.github.io/yq/#xml-support):
|
|
|
```
|
|
|
xq < stats.xml > stats.json
|
|
|
```
|
... | ... | @@ -79,9 +83,9 @@ MALLOCED: 13.3MiB == 13.3MiB |
|
|
### Measuring Memory Externally
|
|
|
|
|
|
The rule of thumb is
|
|
|
> Don't use the 'top' command
|
|
|
> Don't use the `top` command
|
|
|
|
|
|
There are better tools that are less misleading. There are two tools the are easily available on modern Linux systems - **pmap** and **smem**.
|
|
|
There are better tools that are less misleading. There are two tools the are easily available on modern Linux systems - `pmap` and `smem`.
|
|
|
|
|
|
#### pmap
|
|
|
|
... | ... | |