Re: Detecting memory leaks with libpq? - Mailing list pgsql-general

From Ben Chobot
Subject Re: Detecting memory leaks with libpq?
Date
Msg-id 6EF083F6-5B11-435E-9423-BF67FF088AD9@silentmedia.com
Whole thread Raw
In response to Re: Detecting memory leaks with libpq?  (Craig Ringer <craig@postnewspapers.com.au>)
Responses Re: Detecting memory leaks with libpq?
List 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
astructure that's allocated only once during init and never messed with afterwards. The OS clears the memory anyway, so
free()ingit 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
freeingthem - even after they're no longer valid - is just sloppy code. By the same logic, dangling pointers are A-OK,
solong 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
OSwon'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. :)

pgsql-general by date:

Previous
From: Scott Ribe
Date:
Subject: announcements regarding tools
Next
From: Leif Biberg Kristensen
Date:
Subject: Re: announcements regarding tools