Py_Finalize

Gerhard Häring gh at ghaering.de
Fri Feb 20 09:02:05 EST 2004


Pablo Yabo wrote:
> Hi,
> I embeded Python in a C++ application to support some scripts. I start it
> using Py_Initialize() and after using running the scripts I call
> Py_Finalize(). The problem that I experienced is that the memory usage of
> the process doesn't decrease after the Py_Finalize().
> If I call again Py_Initialize() and then load some modules, the memory usage
> increase, but it never decrease when calling Py_Finalize().
> How can I do a complete cleanup of the python heap?

Chances are everything is working fine, but your C library isn't returning freed 
memory to the operating system.

Try runnnig Py_Initialize()/your scripts/Py_Finalize() in a loop. If memory usage 
doesn't increase above a certain maximum, then you don't have any leaks.

-- Gerhard




More information about the Python-list mailing list