Re: Python memory handling



* Chris Mellon (Thu, 31 May 2007 12:10:07 -0500)
Like:
import pool
pool.free()
pool.limit(size in megabytes)

Why not letting the user choosing that, why not giving the user more
flexibility ?
I will try later under linux with the latest stable python

Regards,
FP


The idea that memory allocated to a process but not being used is a
"cost" is really a fallacy, at least on modern virtual memory sytems.
It matters more for fully GCed languages, where the entire working set
needs to be scanned, but the Python GC is only for breaking refcounts
and doesn't need to scan the entire memory space.

There are some corner cases where it matters, and thats why it was
addressed for 2.5, but in general it's not something that you need to
worry about.

If it's swapped to disk than this is a big concern. If your Python app
allocates 600 MB of RAM and does not use 550 MB after one minute and
this unused memory gets into the page file then the Operating System
has to allocate and write 550 MB onto your hard disk. Big deal.

Thorsten
.



Relevant Pages

  • Re: Memory Allocation?
    ... For example, consider a dict. ... allocates a dict object, a hash table to hold the values, and the ... So how much memory is used by x? ... You'll have to make some assumptions about Python internals and it ...
    (comp.lang.python)
  • Re: Python memory handling
    ... > "cost" is really a fallacy, at least on modern virtual memory sytems. ... but the Python GC is only for breaking refcounts ... allocates 600 MB of RAM and does not use 550 MB after one minute and ... has to allocate and write 550 MB onto your hard disk. ...
    (comp.lang.python)
  • Re: Framework 2.0 array redim unsatisfactory performance
    ... implementation details of Redim, Redim Preserve, and List. ... significantly higher object allocated overhead then List. ... ReDim simply allocates a new ... but I do not even attempt to test its memory ...
    (microsoft.public.dotnet.languages.vb)
  • Re: 2.6, 3.0, and truly independent intepreters
    ... just the GIL being in place, but of course it's there for a reason. ... Python faster on single core machines and more stable on multi core ... Other language designers think the same way. ... with languages that use memory pointers, have the potential to get out ...
    (comp.lang.python)
  • Re: why cannot assign to function call
    ... a porch the same if all its ... actual Python objects tend to be mutable only if they are ... In CPython, the id is given by the memory location of the object, which ... significant changes and replacements and add-ons that nevertheless don't ...
    (comp.lang.python)