[[["容易理解","easyToUnderstand","thumb-up"],["確實解決了我的問題","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["難以理解","hardToUnderstand","thumb-down"],["資訊或程式碼範例有誤","incorrectInformationOrSampleCode","thumb-down"],["缺少我需要的資訊/範例","missingTheInformationSamplesINeed","thumb-down"],["翻譯問題","translationIssue","thumb-down"],["其他","otherDown","thumb-down"]],["上次更新時間:2025-09-04 (世界標準時間)。"],[[["\u003cp\u003eAlloyDB Omni employs adaptive algorithms to manage memory, automatically adjusting the shared buffer size for optimal performance.\u003c/p\u003e\n"],["\u003cp\u003eBy default, the shared buffer's upper limit is set to 80% of the system memory, but it begins at 10% of this limit, scaling up or down as needed.\u003c/p\u003e\n"],["\u003cp\u003eUsers can customize the shared buffer's upper limit by modifying the \u003ccode\u003eshared_buffers\u003c/code\u003e parameter in the \u003ccode\u003epostgresql.conf\u003c/code\u003e file or via docker run commands.\u003c/p\u003e\n"],["\u003cp\u003eAlloyDB Omni's memory management is independent of the columnar engine's memory, and when both are enabled, shared buffer calculations account for the columnar engine's memory usage.\u003c/p\u003e\n"],["\u003cp\u003eAlloyDB Omni prioritizes huge pages for improved performance and will log warnings with instructions for setup if huge pages aren't natively supported.\u003c/p\u003e\n"]]],[],null,["# About automatic memory management\n\nSelect a documentation version: 15.7.1keyboard_arrow_down\n\n- [Current (16.8.0)](/alloydb/omni/current/docs/automatic-memory-management)\n- [16.8.0](/alloydb/omni/16.8.0/docs/automatic-memory-management)\n- [16.3.0](/alloydb/omni/16.3.0/docs/automatic-memory-management)\n- [15.12.0](/alloydb/omni/15.12.0/docs/automatic-memory-management)\n- [15.7.1](/alloydb/omni/15.7.1/docs/automatic-memory-management)\n- [15.7.0](/alloydb/omni/15.7.0/docs/automatic-memory-management)\n- [15.5.5](/alloydb/omni/15.5.5/docs/automatic-memory-management)\n- [15.5.4](/alloydb/omni/15.5.4/docs/automatic-memory-management)\n\n\u003cbr /\u003e\n\nAlloyDB Omni uses adaptive algorithms for memory management.\n\n\u003cbr /\u003e\n\nYou can decide the upper limit of the shared buffer on starting AlloyDB Omni. If you don't set the upper limit, AlloyDB Omni automatically sets the shared buffer backing up size to 80% of system memory. The initial backing up size of the shared buffer can be different from the upper limit.\n\nAlloyDB Omni consists of an intelligent memory worker which constantly monitors the memory status, and tunes shared buffer backing up size for best performance when caching data.\n\nBy default the `shared_buffers` parameter is set to `0` which is a special value that sets the upper limit of the size of the `shared buffers` cache to 80% of system memory. AlloyDB Omni starts at 10% of the `shared_buffers` upper limit. If `shared_buffers` is overridden by a custom value, then AlloyDB Omni respects the value as the upper limit of the `shared_buffers` size, and starts with that specified custom size.\n| **Note:** Memory worker can still decide to shrink, and later grow shared buffer backing up size at runtime.\n\nTo specify a custom size, edit the `postgresql.conf` configuration file. For example, you can set `shared_buffers` to `1GB` using either of the following:\n\n- `docker run --name `\u003cvar translate=\"no\"\u003eCONTAINER_NAME\u003c/var\u003e` -e INITDB_ARGS=\"-c shared_buffers=1GB\" $image`\n\n- `docker run --name `\u003cvar translate=\"no\"\u003eCONTAINER_NAME\u003c/var\u003e` $image -c shared_buffers=1GB`\n\n Replace \u003cvar translate=\"no\"\u003eCONTAINER_NAME\u003c/var\u003e with the name that you assigned to the AlloyDB Omni container when you installed it.\n\nOptimize query performance\n--------------------------\n\nThe default value of the `shared_buffers` parameter works for common scenarios.\n\nHowever, you can tune the value for best performance.\nIf you choose to rely on the default value of `shared_buffers` to deduce the shared buffer upper limit, then use the cgroup `memory.max` value to influence the computation.\n\nColumnar engine memory\n----------------------\n\nThe dynamic `shared_buffers` is independent of the [columnar engine memory](/alloydb/omni/15.7.1/docs/columnar-engine/configure). When the columnar engine is enabled, the dynamic `shared_buffers` size can be derived by subtracting the amount of memory used by the columnar engine from 80% of the total memory available to the system or cgroup.\n\nHuge pages\n----------\n\nHuge pages improve database performance. AlloyDB Omni manages huge pages explicitly if possible, otherwise it relies on the transparent huge pages (THP) feature of the operating system. If neither huge page type is supported, AlloyDB Omni falls back to 4k page, and prints a warning in docker container logs `docker logs $container_name` with specific instructions to set up huge pages. See [Start AlloyDB Omni](/alloydb/omni/15.7.1/docs/run-connect#start) for instructions how to start a container.\n\nThe warning looks similar to the following: \n\n HINT: Please either execute the all-in-one setup script:\n docker run --rm --privileged $image setup-host\n OR manually execute:\n echo within_size | sudo tee /sys/kernel/mm/transparent_hugepage/shmem_enabled\n sudo sysctl -w vm.nr_overcommit_hugepages=1048576\n\nAutomatic memory management at runtime\n--------------------------------------\n\nAlloyDB Omni constantly monitors the system load, and adjusts its memory consumptions for better performance. Specifically, you might observe the following:\n\n**Dynamic `shared_buffers` size change**\n : AlloyDB Omni increases the dynamic `shared_buffers` size when the system memory consumption is low, and decreases the size when the system memory consumption is high. To monitor the dynamic `shared_buffers` size, use: \n\n ```bash\n CREATE EXTENSION IF NOT EXISTS g_memory;\n SELECT g_dynamic_shared_size();\n ```\n\n**Termination of a PostgreSQL connection when the system is extremely low on memory**\n : When AlloyDB Omni detects that the system is extremely low on memory, it attempts to delete the most memory-consuming PostgreSQL connections until the load falls back to a reasonable level. When such an event happens, AlloyDB Omni logs the following in docker container logs: \n\n ```bash\n WARNING: Sending SIGTERM to pid=xxx NSpid=xxx (VA size = xxxMB) (RSS size = xxxMB)\n ```"]]