Re: BUG #4496: Memory leak in pg_dump.c? - Mailing list pgsql-bugs

From Tom Lane
Subject Re: BUG #4496: Memory leak in pg_dump.c?
Date
Msg-id 25677.1225397188@sss.pgh.pa.us
Whole thread Raw
In response to Re: BUG #4496: Memory leak in pg_dump.c?  (Aggro <dvice_null@yahoo.com>)
List pgsql-bugs
Aggro <dvice_null@yahoo.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

pgsql-bugs by date:

Previous
From: Alvaro Herrera
Date:
Subject: Re: BUG #4496: Memory leak in pg_dump.c?
Next
From: Tomáš Szépe
Date:
Subject: Re: BUG #4496: Memory leak in pg_dump.c?