Hello,<br><br>Using the best fit for Python will not be a problem, because Python makes allocations of lot of small size blocks.So those split blocks of small sizes are used by Python sometime. And what I observed from my investigation with the memory manager(MM) for Python is , with any MM we cannot eliminate fragmentation and even though  Python is memory hungry I cannot allot some 50MB (or more) just for python application because it will add to the embedded system memory cost.
<br>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:<br>1) Py_Finalize( )
<br>2) Reset my Memory pool (i.e. free list links)<br>3) Then Restart Python by calling Py_Initialize().<br><br>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.<br><br><br>Vishnu<br> <br><br>On 6/10/07, MRAB <
<a href="mailto:google@mrabarnett.plus.com">google@mrabarnett.plus.com</a>> wrote:<br>> On Jun 9, 1:33 pm, vishnu <<a href="mailto:gkkvis...@gmail.com">gkkvis...@gmail.com</a>> wrote:<br>> > Hi,<br>> > Thanks Cameron for your suggestions.
<br>> > In fact I am using custom memory sub-allocator where I preallocate a<br>> > pool of memory during initialization of my application and ensure that<br>> > Python doesn't make any system mallocs later . With this arrangement,
<br>> > python seems to run out of preallocated memory (of 10MB) after running<br>> > few simple scripts due to huge external fragmentation. My memory<br>> > sub-allocator got a good design which uses the best-fit algorithm and
<br>> > coaelescing the adjacent blocks during each free call.<br>> > If anybody out there used their own memory manager and ran Python<br>> > without fragmentation , could provide some inputs on this.<br>
> ><br>> >From what I remember, the best-fit algorithm isn't a good idea because<br>> unless the free block was exactly the right size you'd tend to get<br>> left with lots of small fragments. (Suppose that the best fit was a
<br>> free block only 4 bytes bigger than what you want; what can you do<br>> with a free block of 4 bytes?)<br>> <br>> A worst-fit algorithm would leave larger free blocks which are more<br>> useful subsequently, but I think that the recommendation was next-fit
<br>> (ie use the first free block that's big enough, starting from where<br>> you found the last one).<br>> <br>> --<br>> <a href="http://mail.python.org/mailman/listinfo/python-list">http://mail.python.org/mailman/listinfo/python-list
</a><br>> <br>