Select a documentation version: <button class="button button-with-icon cloud-select-dropdown__button button-primary" aria-haspopup="true">17.5.0</button>

- [Current (18.4.0)](https://docs.cloud.google.com/alloydb/omni/kubernetes/current/docs/analyze-memory-heap-usage.md.txt)
- [18.4.0](https://docs.cloud.google.com/alloydb/omni/kubernetes/18.4.0/docs/analyze-memory-heap-usage.md.txt)
- [18.3.0](https://docs.cloud.google.com/alloydb/omni/kubernetes/18.3.0/docs/analyze-memory-heap-usage.md.txt)
- [18.1.0](https://docs.cloud.google.com/alloydb/omni/kubernetes/18.1.0/docs/analyze-memory-heap-usage.md.txt)
- [17.10.0](https://docs.cloud.google.com/alloydb/omni/kubernetes/17.10.0/docs/analyze-memory-heap-usage.md.txt)
- [17.9.0](https://docs.cloud.google.com/alloydb/omni/kubernetes/17.9.0/docs/analyze-memory-heap-usage.md.txt)
- [17.7.0](https://docs.cloud.google.com/alloydb/omni/kubernetes/17.7.0/docs/analyze-memory-heap-usage.md.txt)
- [17.5.0](https://docs.cloud.google.com/alloydb/omni/kubernetes/17.5.0/docs/analyze-memory-heap-usage.md.txt)
- [16.14.0](https://docs.cloud.google.com/alloydb/omni/kubernetes/16.14.0/docs/analyze-memory-heap-usage.md.txt)
- [16.13.0](https://docs.cloud.google.com/alloydb/omni/kubernetes/16.13.0/docs/analyze-memory-heap-usage.md.txt)
- [16.11.0](https://docs.cloud.google.com/alloydb/omni/kubernetes/16.11.0/docs/analyze-memory-heap-usage.md.txt)
- [16.9.0](https://docs.cloud.google.com/alloydb/omni/kubernetes/16.9.0/docs/analyze-memory-heap-usage.md.txt)
- [16.8.0](https://docs.cloud.google.com/alloydb/omni/kubernetes/16.8.0/docs/analyze-memory-heap-usage.md.txt)
- [16.3.0](https://docs.cloud.google.com/alloydb/omni/kubernetes/16.3.0/docs/analyze-memory-heap-usage.md.txt)
- [15.18.0](https://docs.cloud.google.com/alloydb/omni/kubernetes/15.18.0/docs/analyze-memory-heap-usage.md.txt)
- [15.17.0](https://docs.cloud.google.com/alloydb/omni/kubernetes/15.17.0/docs/analyze-memory-heap-usage.md.txt)
- [15.15.0](https://docs.cloud.google.com/alloydb/omni/kubernetes/15.15.0/docs/analyze-memory-heap-usage.md.txt)
- [15.13.0](https://docs.cloud.google.com/alloydb/omni/kubernetes/15.13.0/docs/analyze-memory-heap-usage.md.txt)
- [15.12.0](https://docs.cloud.google.com/alloydb/omni/kubernetes/15.12.0/docs/analyze-memory-heap-usage.md.txt)
- [15.7.1](https://docs.cloud.google.com/alloydb/omni/kubernetes/15.7.1/docs/analyze-memory-heap-usage.md.txt)
- [15.7.0](https://docs.cloud.google.com/alloydb/omni/kubernetes/15.7.0/docs/analyze-memory-heap-usage.md.txt)

<br />

This document describes how you can get a snapshot of the memory heap of AlloyDB Omni operator to help diagnose and debug potential memory issues. Use the following steps to get a memory heap for analysis:

<br />

1. Determine which AlloyDB Omni operator deployment to analyze. The
   AlloyDB Omni operator includes two deployments, and you can analyze
   the memory heap for either one. To identify the two deployments, run the
   following command:

   ```bash
   kubectl get deployment -n alloydb-omni-system
   ```

   The output shows you the two deployments in the `alloydb-omni-system`
   namespace:
   - `fleet-controller-manager`
   - `local-controller-manager`

   You can get the memory heap of either deployment. For demonstration purposes,
   these steps show how to get the memory heap for the
   `local-controller-manager` deployment.
2. Turn on memory analysis by specifying an available port to use. After the
   port is specified, the pod restarts. To specify an available port, use the
   `pprof-address` argument in the deployment:

   1. Open the deployment in a text editor by running the following command:

      ```bash
      kubectl edit -n alloydb-omni-system deploy local-controller-manager
      ```
   2. Specify the port in the `args` of the `container` section in the template
      `spec`:

      ```yaml
      apiVersion: apps/v1
      kind: Deployment
      spec:
        ...
        template:
        ...
          spec:
            containers:
            - args
              - --pprof-address=:PORT
      ```

      > [!IMPORTANT]
      > **Important:** To prevent malicious use of the feature, turn off memory analysis by removing this port argument when you finish analyzing the memory heap.

   3. Save the deployment file. After you save the deployment file, the pod
      restarts.

3. Wait for the pod to restart before continuing to the next step.

   To make sure the pod restarted, run the following command:

   ```bash
   kubectl get pod -n alloydb-omni-system
   ```

   Verify that the output value in the pod's `STATUS` column is `Running` and the
   output value in its `AGE` column is a short duration. For example, if the
   `STATUS` column is `Running` and the value in the `AGE` column is `50s`, then
   the pod has been running for 50 seconds after the restart.
4. Turn on port forwarding using the following command:

   ```bash
   kubectl port-forward -n alloydb-omni-system DEPLOYMENT_POD_NAME PORT:PORT
   ```

   Replace <var translate="no">DEPLOYMENT_POD_NAME</var> with the name of your deployment as it
   appears in the `NAME` column of the output of the following command:

   ```bash
   kubectl get pod -n alloydb-omni-system
   ```
5. In a different terminal, run the following command to create a file with a
   snapshot of the memory heap of the deployment:

   ```bash
   curl http://localhost:PORT/debug/pprof/heap > heap.out
   ```
6. Save the `heap.out` file and use it to view the memory heap of the
   AlloyDB Omni operator deployment you chose to analyze.

7. Turn off memory analysis by removing the `pprof-address` argument with the
   port you used from the deployment:

   1. Open the deployment in a text editor:

      ```bash
      kubectl edit -n alloydb-omni-system deploy local-controller-manager
      ```
   2. Remove the port `--pprof-address=:PORT` line from the
      `args` of the `container` section in template `spec` that you added
      earlier.

## What's next

- [Manage and monitor AlloyDB Omni](https://docs.cloud.google.com/alloydb/omni/kubernetes/17.5.0/docs/manage.md.txt)