> For the complete documentation index, see [llms.txt](https://docs.postgresql.tw/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.postgresql.tw/19/internals/views/view-pg-shmem-allocations.md). Agents can also search and read this documentation through its [MCP server](https://docs.postgresql.tw/~gitbook/mcp).

# 53.27. pg\_shmem\_allocations \#

### 53.27. `pg_shmem_allocations` [#](#view-pg-shmem-allocations) <a href="#view-pg-shmem-allocations" id="view-pg-shmem-allocations"></a>

檢視表 `pg_shmem_allocations` 顯示從伺服器主要共享記憶體區段所進行的配置。這包含 PostgreSQL 本身所配置的記憶體，以及擴充功能使用[第 36.10.11 節](https://docs.postgresql.tw/19/server-programming/extend/xfunc-c.md#xfunc-shared-addin)所詳述之機制配置的記憶體。

請注意，此檢視表不包含使用動態共享記憶體基礎架構所配置的記憶體。

#### 表 53.27. `pg_shmem_allocations` 欄位 [#](#view-pg-shmem-allocations-columns) <a href="#view-pg-shmem-allocations-columns" id="view-pg-shmem-allocations-columns"></a>

| <p>欄位類型</p><p>說明</p>                                                                                                                                                                        |
| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| <p><code>name</code> <code>text</code></p><p>共享記憶體配置的名稱。未使用的記憶體為 NULL，匿名配置則為 <code>\<anonymous></code>。</p>                                                                                 |
| <p><code>off</code> <code>int8</code></p><p>配置起始處的位移量。匿名配置則為 NULL，因為與其相關的細節是未知的。</p>                                                                                                        |
| <p><code>size</code> <code>int8</code></p><p>配置的大小（以位元組為單位）</p>                                                                                                                             |
| <p><code>allocated\_size</code> <code>int8</code></p><p>配置的大小（以位元組為單位，含填補）。對於匿名配置，沒有關於填補的資訊可用，因此 <code>size</code> 與 <code>allocated\_size</code> 欄位一律相等。填補對閒置記憶體沒有意義，因此在該情況下這兩個欄位也會相等。</p> |

<br>

匿名配置是指直接以 `ShmemAlloc()` 進行的配置，而不是透過 `ShmemInitStruct()` 或 `ShmemInitHash()` 進行的配置。

預設情況下，只有超級使用者或具有 `pg_read_all_stats` 角色權限的角色可讀取 `pg_shmem_allocations` 檢視表。

***

原文：[PostgreSQL 18.6 Documentation](https://www.postgresql.org/docs/18/view-pg-shmem-allocations.html)（原文版本：18.6；核對日期：2026-10-09）


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.postgresql.tw/19/internals/views/view-pg-shmem-allocations.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
