Issue 4872: Python will not co-exist with MFC (memory leak) (original) (raw)

Issue4872

Created on 2009-01-07 21:55 by nqiang, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Messages (3)
msg79375 - (view) Author: nqiang (nqiang) Date: 2009-01-07 21:55
The following code will cause memory leak in debug mode using visual studio 2008/2005 Comment out either MFC related (CString s) or Python related PY_XX. Then there will be no memory leak. #include <python.h> #include <afx.h> int _tmain(int argc, _TCHAR* argv[]) { Py_Initialize(); Py_Finalize(); CString s; return 0; }
msg79377 - (view) Author: Martin v. Löwis (loewis) * (Python committer) Date: 2009-01-07 22:27
How do you know that there is a memory leak? I find it very unlikely that this interaction could cause a memory leak (although it is plausible that in this case, not all memory is returned to the system - which is something different from a memory leak).
msg118034 - (view) Author: Amaury Forgeot d'Arc (amaury.forgeotdarc) * (Python committer) Date: 2010-10-05 21:32
- The "memory leaks" are reported in the IDE output window when the process exits; this lists all non deallocated blocks of memory. This feature is not enabled by default. Creating a CString probably initializes this feature. - Py_Finalize() doesn't free all memory used by Py_Initialize(); this is not a problem, as long as a second call to Py_Initialize() reuses the same memory. Closing as "won't fix": there is no need to free everything when the process exits.
History
Date User Action Args
2022-04-11 14:56:43 admin set github: 49122
2010-10-05 21:32:09 amaury.forgeotdarc set status: pending -> closednosy: + amaury.forgeotdarcmessages: + resolution: not a bug -> wont fix
2010-06-25 22:34:25 terry.reedy set status: open -> pendingresolution: not a bugversions: - Python 2.5, Python 3.0
2009-01-07 22:27:49 loewis set nosy: + loewismessages: +
2009-01-07 21:55:31 nqiang create