On Fri, Oct 4, 2019 at 5:51 AM Natarajan R <nataraj3...@gmail.com> wrote: > Why postgres not providing freeing shared memory?
Because it's intended to be used mostly for data structures that live for the entire server lifetime. There are some cases, such as various hash tables, where the number of entries can grow and shrink over time. It might be useful to return memory that is freed up when the hash table shrinks to the common pool, but it would be complex, because then we'd have to keep track of multiple chunks of freed memory and consolidate adjacent chunks and so forth. I don't see that we'd be likely to get much benefit from such a system, since a lot of cases memory fragmentation would prevent us from getting any real benefit. If you need a shared data structure that is temporary, you might want to check out DSM and DSA. -- Robert Haas EnterpriseDB: http://www.enterprisedb.com The Enterprise PostgreSQL Company