我想弄清楚为什么~30空闲postgres进程在正常使用后占用大量进程特定的内存。我正在使用Postgres 9.3.1和CentOS 6.3版(最终版)。 使用top
,我可以看到,许多Postgres连接的非共享(RES - SHR)是使用高达300MB(平均〜200MB)存储器:空闲postgres进程占用大量内存
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
3534 postgres 20 0 2330m 1.4g 1.1g S 0.0 20.4 1:06.99 postgres: deploy mtalcott 10.222.154.172(53495) idle
9143 postgres 20 0 2221m 1.1g 983m S 0.0 16.9 0:14.75 postgres: deploy mtalcott 10.222.154.167(35811) idle
6026 postgres 20 0 2341m 1.1g 864m S 0.0 16.4 0:46.56 postgres: deploy mtalcott 10.222.154.167(37110) idle
18538 postgres 20 0 2327m 1.1g 865m S 0.0 16.1 2:06.59 postgres: deploy mtalcott 10.222.154.172(47796) idle
1575 postgres 20 0 2358m 1.1g 858m S 0.0 15.9 1:41.76 postgres: deploy mtalcott 10.222.154.172(52560) idle
大约有29总的空闲连接。这些空闲连接在内存中不断增长,直到机器开始使用交换,然后性能下降。如预期的那样,重置连接会清除进程特定的内存。当我定期重新连接时,同一台机器上相同数量的连接只使用20%的内存(使用0交换)。这些过程持有什么样的信息?我希望长期运行的闲置postgres进程可以使用类似的内存来使用全新的闲置进程。
值得注意的是:我大量使用模式。在对我的应用的每个请求中,我正在设置并重置search_path。