Monitoring Memory Resources

Monitoring the Memory

GaussDB(DWS) provides a view for monitoring the memory usage of the entire cluster.

Query the pgxc_total_memory_detail view as a user with sysadmin permissions.
1
SELECT * FROM pgxc_total_memory_detail;
If the following error message is returned during the query, enable the memory management function.
1
2
3
SELECT * FROM pgxc_total_memory_detail;
ERROR:  unsupported view for memory protection feature is disabled.
CONTEXT:  PL/pgSQL function pgxc_total_memory_detail() line 12 at FOR over EXECUTE statement
To enable memory management, you can set enable_memory_limit and max_process_memory on the GaussDB(DWS) console as follows:
  1. Log in to the GaussDB(DWS) management console.
  2. In the navigation pane on the left, click Clusters.
  3. In the cluster list, find the target cluster and click its name. The Basic Information page is displayed.
  4. Click the Parameter Modification tab, change the value of enable_memory_limit to on, and click Save to save the file.
  5. Change the value of max_process_memory to a proper one. For details about the modification suggestions, see max_process_memory. After it is done, click Save.
  6. In the Modification Preview dialog box, confirm the modifications and click Save. After the modification, restart the cluster for the modification to take effect.

Monitoring the Shared Memory

You can query the context information about the shared memory on the pg_shared_memory_detail view.

1
2
3
4
5
6
7
8
9
SELECT * FROM pg_shared_memory_detail;
           contextname           | level |             parent              | totalsize | freesize | usedsize 
---------------------------------+-------+---------------------------------+-----------+----------+----------
 ProcessMemory                   |     0 |                                 |     24576 |     9840 |    14736
 Workload manager memory context |     1 | ProcessMemory                   |   2105400 |     7304 |  2098096
 wlm collector hash table        |     2 | Workload manager memory context |      8192 |     3736 |     4456
 Resource pool hash table        |     2 | Workload manager memory context |     24576 |    15968 |     8608
 wlm cgroup hash table           |     2 | Workload manager memory context |     24576 |    15968 |     8608
(5 rows)

This view lists the context name of the memory, level, the upper-layer memory context, and the total size of the shared memory.

In the database, GUC parameter memory_tracking_mode is used to configure the memory statistics collecting mode, including the following options: