Steve Lane <slane@fmpro.com> writes:
> I seem to be having a problem with the postgres utilities chewing a lot of
> RAM. I've been running PG 7.1 under LinuxPPC on a PowerMac G4. After a few
> days of use, free memory degrades to almost nothing.
This is wrong?
On most Unixen, the kernel happily uses all spare RAM to cache
recently-accessed disk blocks. If you've got large amounts of "free"
RAM it only means that (a) you rebooted recently, or (b) you're not
doing much disk access.
> I logged memory usage
> for a while and found that free memory would suddenly drop by 200-300 meg
> every night at 1:20 AM, right when my nightly maintenance scripts run.
> I traced through the nightly scripts and found that two things seem to
> account for the memory loss -- vacuuming the databases, and backing them up.
> I restarted to free all my RAM back up and tried just those operations. Sure
> enough, after a vacuum verbose analyze (on about thirty tables totaling
> probably less than 50 MB of data), free memory dropped by 130MB. Backing up
> everything on the server took another 110MB. And this memory never gets
> returned.
This all sounds like standard, expected, preferable behavior.
As soon as you run programs that need RAM, the kernel will drop those
disk-cache pages and assign the RAM to program space. But as long as
you don't, what else should the kernel do with unused RAM than keep disk
cache in it?
regards, tom lane