Is there a memory leakage in this embedded python code?

K

kiran kumar

Hi All,
I am working on embedded python on C these days. I feel there is a
memory leakage in this code. I have used our own memory pool and all
the python code will use the heap from this memory pool.
RunScript(pScriptName,pFuncName,...)
{
PyEval_AcquireLock()
threadState = Py_NewInterpreter();
PyThreadState_Swap(threadState);

/* Import the script module and run the fnc in that script module */
Pyobject *pModule = PyImport_Import(pScriptName);
PyObject *pFunc = PyObject_GetAttrString(pModule, pFuncName);
.....
/* End running the script and calling the script fnc */
Py_EndInterpreter(threadState);
PyEval_ReleaseLock();
}

Befor running this code i checked my memory heap pool available
memory. Then i called the above function to run my script script1.py.
Script ran succesfully, but after completion of the above fnc, when i
checked the memory there is a huge KB of memory is used by this code.
I have no doubt on my memory pool implementation, bcoz it isworking
from many years.
Now, My doubt is, when i call Py_EndInterpreter at the end does it not
clear the whole memory which was used in executing the script? Or
still the imported stuff from the script1.py is in memory only?

Would greatly appreciate the help....

vishnu
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,037
Messages
2,570,371
Members
47,014
Latest member
TashaMorei

Latest Threads

Top