diff --git a/pages/database-management/debugging.mdx b/pages/database-management/debugging.mdx index ed0b0c399..0e45245ac 100644 --- a/pages/database-management/debugging.mdx +++ b/pages/database-management/debugging.mdx @@ -235,6 +235,69 @@ services: ``` +### Using `heaptrack` with Docker + +All `RelWithDebInfo` images come with `heaptrack` installed. You can use it to track the memory usage of Memgraph. + +Before starting the container, create a directory to store the heaptrack data: + +```bash +mkdir -p /tmp/heaptrack +chmod a+rwx /tmp/heaptrack +``` + +Then start the container with the following command: + +```bash +docker run -d --rm \ + --name memgraph \ + -v /tmp/heaptrack:/data \ + --entrypoint /usr/bin/heaptrack \ + memgraph/memgraph:3.6.1-relwithdebinfo \ + --output /data/heaptrack.memgraph \ + -- \ + /usr/lib/memgraph/memgraph +``` + + + Running the MAGE container using this method will result in a segmentation fault due to the way + that `heaptrack` interacts with Python, so memgraph should be launched by `heaptrack` using the `--use-inject` flag: + + ```bash + docker run -d --rm \ + --name memgraph \ + -p 7687:7687 \ + -v /tmp/heaptrack:/data \ + --entrypoint /usr/bin/heaptrack \ + memgraph/memgraph-mage:3.6.1-relwithdebinfo \ + --output /data/heaptrack.memgraph \ + --use-inject /usr/lib/memgraph/memgraph + ``` + + +To stop `memgraph` gracefully: + +```bash +docker exec memgraph bash -c "kill -SIGINT \$(pidof memgraph)" +``` + +Then the `heaptrack` GUI can be used to inspect the heaptrack data on the host machine: + +```bash +heaptrack /tmp/heaptrack/heaptrack.memgraph.gz +``` + + + The `heaptrack` GUI can be installed on the host machine by issuing the command (Debian/Ubuntu): + ```bash + sudo apt install heaptrack + ``` + or by issuing the command (Fedora): + ```bash + sudo dnf install heaptrack + ``` + + ### Profiling with `perf` Perfing is the most common operation that is run when Memgraph is hanging or