msg147785 - (view) |
Author: Asesh (Asesh) |
Date: 2011-11-17 00:57 |
Well I just finished embedding Python in my application but even after calling Py_Finalize the debugger shows tons of memory leak. I just called Py_Initialize and then Py_Finalize then after exiting the application, the Visual C++ debugger shows tons of memory leaks and Python is to be blamed: Detected memory leaks! Dumping objects -> {3478} normal block at 0x00000000026343E0, 912 bytes long. Data: < po > 00 00 00 00 00 00 03 70 6F FB FB FB FB FB FB FB {3476} normal block at 0x0000000002633DA0, 912 bytes long. Data: < po > 00 00 00 00 00 00 03 70 6F FB FB FB FB FB FB FB {3474} normal block at 0x000000000261AC70, 912 bytes long. Data: < po > 00 00 00 00 00 00 03 70 6F FB FB FB FB FB FB FB {3472} normal block at 0x000000000261A620, 912 bytes long. Data: < po > 00 00 00 00 00 00 03 70 6F FB FB FB FB FB FB FB {3471} normal block at 0x000000000261B540, 912 bytes long. Data: < po > 00 00 00 00 00 00 03 70 6F FB FB FB FB FB FB FB {3470} normal block at 0x00000000025C66B0, 800 bytes long. Data: < m > 00 00 00 00 00 00 03 00 6D FB FB FB FB FB FB FB ... // Skipped posting more memory leaks ... {63} normal block at 0x0000000001D927D0, 108 bytes long. Data: <C : \ U s e r s > 43 00 3A 00 5C 00 55 00 73 00 65 00 72 00 73 00 Object dump complete. The program '[6696] cScripting.exe: Native' has exited with code 0 (0x0). Upon Googling, seems like am not the only one. I have attached a small project that demonstrates it. It's a x64 build and you'll have to adjust the path of the lib folder |
|
|
msg147786 - (view) |
Author: STINNER Victor (vstinner) *  |
Date: 2011-11-17 01:00 |
(The project example uses _CrtSetDbgFlag(_CRTDBG_LEAK_CHECK_DF | _CRTDBG_ALLOC_MEM_DF) to perform memory leak check.) |
|
|
msg147791 - (view) |
Author: Amaury Forgeot d'Arc (amaury.forgeotdarc) *  |
Date: 2011-11-17 08:05 |
These are not memory leaks, but global state that the Python interpreter does not bother to free on exit. The amount of memory there is limited. Yes, I agree that this makes the basic memory checker built in Visual Studio completely useless. |
|
|
msg147793 - (view) |
Author: Asesh (Asesh) |
Date: 2011-11-17 10:37 |
ok thanks for the replies. Actually I have python embedded in my game but now the real problem now is how do I differentiate from the real memory leak caused either by Python or by my application? Disabling memory leak check is not an option since it's been very helpful when debugging my C++ apps |
|
|
msg147981 - (view) |
Author: Martin v. Löwis (loewis) *  |
Date: 2011-11-20 10:11 |
If you *really* want to solve this problem, you could start working on making Python release all memory at interpreter shutdown. Please understand that this project may well take several years to complete, but it would help not only your project, but also many people in a similar situation. Meanwhile, you should use a better memory checker, one where you can declare that it shall ignore certain allocations. |
|
|
msg148045 - (view) |
Author: Asesh (Asesh) |
Date: 2011-11-21 14:39 |
@Martin v. Löwis (loewis): thanks, I will try to do so in my free time |
|
|
msg192674 - (view) |
Author: Christian Heimes (christian.heimes) *  |
Date: 2013-07-08 17:11 |
Martin, can we close this issue or do you want to keep it around? |
|
|
msg192757 - (view) |
Author: Martin v. Löwis (loewis) *  |
Date: 2013-07-09 15:13 |
Ok, closing it. |
|
|