Search Postgresql Archives

Re: Detecting memory leaks with libpq?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 





On Tue, Jul 19, 2011 at 5:41 AM, Antonio Vieiro <antonio@xxxxxxxxxxxxxxxx> wrote:
Hi all,

I'm building a small C application that uses libpq and I was wondering
if there's an easy way to detect memory leaks in my code.

I think I'm calling PQclear and friends correctly, but I'd like to
double-check it. I was wondering if there's a function in libpq to
check memory-use usage/internals, or something like that.

Wrap your main logic in a loop that runs it 100,000 or more times.  However, the process itself should never exit (eg, only ever exist as one pid).  As the process runs, monitor it with top, htop (really nice util for Linux), vmstat, etc...  Does the memory usage go up and up, generally linearly with time?

Run the same process using "electronic fence" [1] or "valgrind" [2].

[1] http://linux.die.net/man/3/efence  (not for finding memory leaks per se, but useful for finding memory mis-usage.
[2] http://valgrind.org/


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux