Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
63 changes: 63 additions & 0 deletions pages/database-management/debugging.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -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
```

<Callout>
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
```
</Callout>

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
```

<Callout>
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
```
</Callout>

### Profiling with `perf`

Perfing is the most common operation that is run when Memgraph is hanging or
Expand Down