Repository navigation
Live Monitoring
memlogger runs a dedicated background thread that periodically updates peak allocation statistics. If MEMLOGGER_LOG_FILENAME is set, the thread also writes the current allocation report to the specified file after each update.
The file always contains the latest snapshot and is replaced on each update; it is not an append-only log.
tail -f is not suitable for this file. It follows the current file position and is intended primarily for append-only logs. Since memlogger periodically rewrites the report, tail -f may lose its position when the file is truncated and rewritten.
A simple live viewer can be used instead.
Create a small memlogger-watch script:
#!/bin/sh
while :; do
printf '\033[H\033[2J'
cat "$1"
sleep 1
doneMake the script executable:
chmod +x memlogger-watchThen run it with the report filename:
memlogger-watch /tmp/memory.logThe report will be refreshed once per second.
The script uses only standard shell utilities and terminal control sequences. No watch utility or other non-standard tool is required.
Alternatively, if your shell supports functions, the viewer can be defined directly in the shell profile:
memwatch() {
while :; do
printf '\033[H\033[2J'
cat "$1"
sleep 1
done
}Then run it with the report filename:
memwatch /tmp/memory.logThe profiler does not write every allocation event to the report file. Allocation activity is aggregated in memory using fixed-size statistical structures. The reporting thread periodically generates a report from the current counters and writes that report to the configured file.
This keeps the normal profiling path independent of file I/O and avoids turning the report into an event log that would require subsequent parsing and aggregation.
The report file is intended to provide a convenient current view of the profiler state. For real-time monitoring, use memlogger-watch or memwatch rather than tail -f.