- 追加された行はこの色です。
- 削除された行はこの色です。
#author("2020-01-03T02:57:52+00:00","default:haikikyou","haikikyou")
#author("2020-01-03T15:21:55+00:00","default:haikikyou","haikikyou")
[[PostgreSQL/解析]]
#contents
* Memory Context [#ed0f9858]
-フラットなメモリ空間を構造化して管理するための機能であり、backendで用いられる。
-メモリコンテキストの初期化時、TopMemoryContextとErrorContextが作成される。この他、トップレベルのメモリコンテキストには、PostmasterContext、CacheMemoryContext、MessageContext、TopTransactionContext、CurTransactionContextがあり、TopMemoryContextは、全てのメモリコンテキストの親である。~
&label(warn){参考};
-[[src/backend/utils/mmgr/mcxt.c>https://git.postgresql.org/gitweb/?p=postgresql.git;a=blob;f=src/backend/utils/mmgr/mcxt.c;h=b07be1223698a094f1b3a41ac59370d2b3d1cdb7;hb=refs/heads/REL_12_STABLE]] - &size(11){&color(gray){https://git.postgresql.org/gitweb/?p=postgresql.git;a=tree;h=refs/heads/REL_12_STABLE};};
- [[src/backend/utils/mmgr/README>https://git.postgresql.org/gitweb/?p=postgresql.git;a=blob;f=src/backend/utils/mmgr/README;h=7e6541d0dee2783065b66cd6482478c298dec7a9;hb=refs/heads/REL_12_STABLE]] - &size(11){&color(gray){https://git.postgresql.org/gitweb/?p=postgresql.git;a=tree;h=refs/heads/REL_12_STABLE};};
- メモリコンテキストはツリーの階層で管理される。ノードは1つの親に属する。
- メモリコンテキストは、それぞれ独立したメモリ領域を持つ。親子の関連は、メモリ使用量とは関係ない。
* Memory Contextの操作 [#c06be0e1]
Memory Contextを使用することで、メモリ管理が容易になり、メモリリークのバグも減らせる。~
基本的なメモリコンテキストの操作は以下の図の通りである。
&ref(./memory-context-overview.png,100%);
* AllocSetContext [#y03a961f]
ベースとなるMemoryContextの実装は、AllocSetである。~
AllocSet
* 参考リンク [#zbd54bd5]
- [[PostgreSQL Internals>https://www.postgresqlinternals.org/chapter5/]] - &size(11){&color(gray){on https://www.postgresqlinternals.org/chapter5/};};