"High water" Memory fragmentation still a thing?

Steven D'Aprano steve+comp.lang.python at pearwood.info
Fri Oct 3 21:02:02 EDT 2014


Chris Angelico wrote:

> In theory, a high
> level language like Python would be allowed to move objects around to
> compact memory, but CPython doesn't do this, and there's no proof that
> it'd really help anything anyway.

I welcome correction, but I understand that both the JVM and the CLR memory
managers move memory around. That's why Jython and IronPython use
sequential integers as object IDs, since memory locations are not fixed.

Way back in the mid 1980s, Apple Macintoshes used a memory manager which
could move memory around. Given that the Macs of the day had 128K of RAM,
of which something like a third or a half was used for the screen, being
able to move blocks of memory around to avoid fragmentation was critical,
so I guess that proves that it would help at least one thing.


> (Look at Christian's comments about 
> "Should you return it or not?" and the cost of system calls... now
> consider the orders-of-magnitude worse cost of actually moving memory
> around.)
> 
> This is why a lot of long-duration processes are built to be restarted
> periodically. 

Ironically, the cost of restarting the process periodically is likely to be
orders of magnitude more expensive than that of moving a few blocks of
memory around from time to time. Especially on Windows, where starting
processes is expensive, but even on Linux you have to shut the running
application down, then start it up again and rebuild all the internal data
structures that you just tore down...


-- 
Steven




More information about the Python-list mailing list