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
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