Re: BUG #4496: Memory leak in pg_dump.c?

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Aggro <dvice_null(at)yahoo(dot)com>
Cc: pgsql-bugs(at)postgresql(dot)org
Subject: Re: BUG #4496: Memory leak in pg_dump.c?
Date: 2008-10-30 20:06:28
Message-ID: 25677.1225397188@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

Aggro <dvice_null(at)yahoo(dot)com> writes:
> But is the memory freed at some point? E.g. when
> program shuts down? If it is not freed ever, then it
> is a memory leak.

Program-local memory is *always* freed at process termination. Any
operating system that failed to handle this would be broken beyond
usability, because any simple program crash would lead to loss of
usable memory. Eventually you'd be forced to reboot the OS just
because of application-level bugs.

Now, leakage of the Postgres shared memory segment after a postmaster
crash is a genuine issue. We have some code that tries to detect and
reclaim an orphaned segment, but it's not bulletproof and sometimes
manual cleanup (or a reboot) is needed. (It can't be too aggressive
because the opposite risk, reclaiming a segment that *is* still in
use, would have far worse consequences than a mere memory leak.)

> I'm interested in this, because
> either you have a memory leak or these is a bug in
> another application called cppcheck which claims that
> you have a memory leak.

We don't put too much stock in automatic leak analysis, because
there aren't any automated checkers that understand Postgres'
memory context mechanism. They don't know about shmem either ...

regards, tom lane

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message Tomáš Szépe 2008-10-30 20:25:58 Re: BUG #4496: Memory leak in pg_dump.c?
Previous Message Alvaro Herrera 2008-10-30 20:00:16 Re: BUG #4496: Memory leak in pg_dump.c?