Re: Detecting memory leaks with libpq?

From: Ben Chobot <bench(at)silentmedia(dot)com>
To: Craig Ringer <craig(at)postnewspapers(dot)com(dot)au>
Cc: Antonio Vieiro <antonio(at)antonioshome(dot)net>, pgsql-general(at)postgresql(dot)org
Subject: Re: Detecting memory leaks with libpq?
Date: 2011-07-19 17:43:05
Message-ID: 6EF083F6-5B11-435E-9423-BF67FF088AD9@silentmedia.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Jul 19, 2011, at 6:28 AM, Craig Ringer wrote:

> Note that some "leaks" that are reported are _normal_ in most software. There is absolutely no harm in not free()ing a structure that's allocated only once during init and never messed with afterwards. The OS clears the memory anyway, so free()ing it is just a waste of CPU cycles.

Getting off topic here but "normal" isn't always "desirable." Some might say that allocating singletons and never freeing them - even after they're no longer valid - is just sloppy code. By the same logic, dangling pointers are A-OK, so long as you never use them. So yes, it might be an extra cycle or two to free it now, but that's a cycle or two the OS won't have to do later, and it's almost certainly better to have a cleaner codebase that's 0.000001% slower.

Or so some might argue. :)

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Leif Biberg Kristensen 2011-07-19 18:40:22 Re: announcements regarding tools
Previous Message Scott Ribe 2011-07-19 16:44:46 announcements regarding tools