| Store | Cart

Re: Set x to to None and del x doesn't release memory in python 2.7.1 (HPUX 11.23, ia64)

From: Isaac To <isaa...@gmail.com>
Sat, 9 Mar 2013 23:02:17 +0800
In general, it is hard for any process to return the memory the OS allocate
to it back to the OS, short of exiting the whole process.  The only case
that this works reliably is when the process allocates a chunk of memory by
mmap (which is chosen by libc if it malloc or calloc a large chunk of
memory), and that whole chunk is not needed any more.  In that case the
process can munmap it.  Evidently you are not see that in your program.
What you allocate might be too small (so libc choose to allocate it using
another system call "sbrk"), or that the allocated memory also hold other
objects not freed.

If you want to reduce the footprint of a long running program that
periodically allocates a large chunk of memory, the "easiest" solution is
to fork a different process to achieve the computations that needs the
memory.  That way, you can exit the process after you complete the
computation, and at that point all memory allocated to it is guaranteed to
be freed to the OS.

Modules like multiprocessing probably make the idea sufficiently easy to
implement.


On Sat, Mar 9, 2013 at 4:07 PM, Wong Wah Meng-R32813
<r32...@freescale.com>wrote:

>>>         If the memory usage is continually growing, you have something> else that is a problem -- something is holding onto objects. Even if Python> is not returning memory to the OS, it should be reusing the memory it has> if objects are being freed.> --> [] Yes I have verified my python application is reusing the memory (just> that it doesn't reduce once it has grown) and my python process doesn't> have any issue to run even though it is seen taking up more than 2G in> footprint. My problem is capacity planning on the server whereby since my> python process doesn't release memory back to the OS, the OS wasn't able to> allocate memory when a new process is spawn off.>> --> http://mail.python.org/mailman/listinfo/python-list>

-- 
http://mail.python.org/mailman/listinfo/python-list

Recent Messages in this Thread
Íßêïò Ãêñ33ê Mar 06, 2013 07:45 am
Lele Gaifax Mar 06, 2013 08:19 am
Wong Wah Meng-R32813 Mar 06, 2013 10:11 am
Terry Reedy Mar 06, 2013 10:59 am
Wong Wah Meng-R32813 Mar 06, 2013 12:36 pm
Bryan Devaney Mar 06, 2013 10:25 am
Wong Wah Meng-R32813 Mar 06, 2013 12:31 pm
Dave Angel Mar 06, 2013 01:25 pm
Dave Angel Mar 06, 2013 01:18 pm
Steven DAprano Mar 06, 2013 11:34 pm
Wong Wah Meng-R32813 Mar 07, 2013 06:33 am
Chris Angelico Mar 07, 2013 07:19 am
Wong Wah Meng-R32813 Mar 08, 2013 09:08 am
Wong Wah Meng-R32813 Mar 09, 2013 08:07 am
Dave Angel Mar 09, 2013 11:02 am
Isaac To Mar 09, 2013 03:02 pm
Grant Edwards Mar 09, 2013 07:18 pm
Roy Smith Mar 09, 2013 08:04 pm
Grant Edwards Mar 09, 2013 08:35 pm
Roy Smith Mar 09, 2013 09:44 pm
Grant Edwards Mar 11, 2013 02:27 pm
Mark Lawrence Mar 06, 2013 11:52 am
Chris Angelico Mar 06, 2013 01:40 pm
Michael Ross Mar 06, 2013 02:04 pm
nagi...@gmail.com Mar 06, 2013 04:09 pm
Íßêïò Ãêñ33ê Mar 06, 2013 08:57 am
Lele Gaifax Mar 06, 2013 09:24 am
Íßêïò Ãêñ33ê Mar 06, 2013 09:41 am
Íßêïò Ãêñ33ê Mar 06, 2013 09:43 am
Bryan Devaney Mar 06, 2013 10:15 am
Lele Gaifax Mar 06, 2013 10:27 am
Dave Angel Mar 06, 2013 01:31 pm
Lele Gaifax Mar 06, 2013 02:16 pm
Messages in this thread