[C++-sig] Boost.Python Memory Leaks?

Maximilian Wilson wilson.max at gmail.com
Thu Jun 28 20:30:54 CEST 2007


On 6/28/07, Lawrence Spector <Lawrence.Spector at canfieldsci.com> wrote:
>
>  If this is true, that's a little upsetting to hear.  Boost is supposed to
> be one of the best and most complete libraries ever written.   I haven't
> seen this awful practice elsewhere from within boost.  Not releasing
> dynamically allocated memory is a bad programming practice and is not
> guaranteed to be freed on all platforms (although is on most).  Furthermore,
> any destructors never get called.  The Boost.Python group needs to address
> this issue, because IMHO this is a serious bug/design flaw.
>
>
>
> It also mucks with our tests, because we're working on making a set of
> automated tests and memory leaks are considered a type of failure.  Why
> should poor programming practice inside Boost.Python be an exception?
>
Failing to free dynamically-allocated memory (and call destructors) is
potentially bad for two reasons:

1.) It can lead to resource leakage, with the amount of resources consumed
increasing without limit over time.
2.) When using the RAII paradigm, it can lead to improper management of
external resources.

Python isn't compatible with RAII anyway, since Python destructors are not
deterministic and are not, in fact, even guaranteed to be called AFAIK.
Resource leakage isn't a problem for something which is allocated on the
heap ONCE and never released. Effectively it's a global variable that lives
on the heap.

"Poor programming practice" is a generalization which doesn't apply in this
case.

-Max Wilson

-- 
Be pretty if you are, be witty if you can,
But be cheerful if it kills you.

Everything in Windows is very simple, but the simplest thing is difficult.
    -Clausewitz
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/cplusplus-sig/attachments/20070628/603cc16e/attachment.htm>


More information about the Cplusplus-sig mailing list