#include #include #include int main() { PyObject *mod, *gc, *collect; PyThreadState * tstate, *main_tstate; //Initialize python Py_Initialize(); PyEval_InitThreads(); main_tstate = PyThreadState_Get(); do { tstate = Py_NewInterpreter(); PyThreadState_Swap(tstate); mod = PyImport_ImportModule("large_import"); if(!mod){ printf("Unable to import module"); exit(1); } Py_DECREF(mod); Py_EndInterpreter(tstate); PyThreadState_Swap(main_tstate); gc = PyImport_ImportModule("gc"); if(gc) { collect = PyObject_GetAttrString(gc, "collect"); if(collect) PyObject_CallFunction( collect, NULL); } printf("Relooping...\n"); }while(1); Py_Finalize(); }