Python for embedded systems with memory constraints

Gabriel Genellina gagsl-py2 at yahoo.com.ar
Mon Jun 11 20:55:35 EDT 2007


En Mon, 11 Jun 2007 15:59:19 -0300, vishnu <gkkvishnu at gmail.com> escribió:

> So now I only see the solution to clear my memory pool and restart Python
> without restarting the system (i.e. no power cycle to hardware). I tried  
> to
> do this when my memory pool is 60% used in these steps:
> 1) Py_Finalize( )
> 2) Reset my Memory pool (i.e. free list links)
> 3) Then Restart Python by calling Py_Initialize().
>
> But this resulted in Python  crash during Py_Initialize(), where I found
> that the static variables within embedded Python source code are still
> holding some of the references to my memory pool. So now my question is  
> how
> do I restart Python (i.e. reinitialize Python) without restarting whole
> system. Is there a way to reset/re-initilaize those static variables such
> that it will be possible to re-Initialize Python.

Ouch... I think this should not happen, but anyway I don't know if this  
was a design principle. One should inspect all Python code to locate all  
static variable references... Maybe you could instrument your allocator to  
see which references are still held?
C extensions may be problematic too - there is no way to "uninitialize"  
them, and nothing forbids an extension to hold a reference to any object.

-- 
Gabriel Genellina




More information about the Python-list mailing list