Python Forum
Embedded Python Memory Leaks
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Embedded Python Memory Leaks
#1
Bug 
Hi dear Python team,

I am a building a c/c++ application for general purpose and I would like to have in the application the possibility of running “Python” scripting code. Python has proved to be a good programming language to deal with heavy Math as in AI.

Now when I embed Python in my application things go perfect, except for memory leaks!
As a sample, by just issuing the following code leaves memory leaks of around (2Mb):

#define PY_SSIZE_T_CLEAN
#define Py_LIMITED_API 0x03000000
#include <Python.h>
#pragma comment (lib,"python3.lib")

int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PWSTR pCmdLine, int nCmdShow)
{
    Py_InitializeEx(0); //For Embeded Python
    Py_FinalizeEx();
    ..More code..
    return 0;
}
Is there something I must do to cause Python to release all resources allocated

thanks
Larz60+ write Sep-15-2022, 09:54 PM:
Please post all code, output and errors (it it's entirety) between their respective tags. Refer to BBCode help topic on how to post. Use the "Preview Post" button to make sure the code is presented as you expect before hitting the "Post Reply/Thread" button.
Fixed for you this time. Please use bbcode tags on future posts.

Your indentation is off, and needs fixing
Reply


Messages In This Thread
Embedded Python Memory Leaks - by Alexei - Sep-15-2022, 08:10 PM
RE: Embedded Python Memory Leaks - by Alexei - Sep-16-2022, 01:15 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  How to run detectron2, as python embedded code in C++, on GPU? hassaniqbal931 3 1,144 Nov-02-2023, 04:45 PM
Last Post: blabling2
  Adding libraries to embedded Python as a ZIP The_Oman 0 1,276 May-05-2023, 04:05 PM
Last Post: The_Oman
  python list out top 10 Memory utilisation mg24 0 833 Nov-20-2022, 10:51 PM
Last Post: mg24
  Embedded Python in C++ Xeno 19 3,657 Aug-03-2022, 07:29 AM
Last Post: Gribouillis
  python memory rd_rakesh 1 1,672 Jul-14-2021, 11:15 AM
Last Post: jefsummers
  Embedded python fails to compile on Raspberry Pi tryfon 2 3,522 Dec-22-2020, 02:06 PM
Last Post: tryfon
  Can Embedded Python run any shared library on Android ? sprotz 0 2,347 Nov-08-2020, 12:21 PM
Last Post: sprotz
  Windows Python Memory Scanner Awesometech 1 23,260 Oct-14-2020, 07:44 AM
Last Post: badengagen
  memory leak on embedded python in c++ asdf3721 3 3,433 Jul-16-2020, 06:33 AM
Last Post: Gribouillis
  Embedded Python PyObject_CallObject function JRHeisey 1 2,420 Nov-27-2019, 01:50 AM
Last Post: casevh

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020