The reason why SmartMap never releases the memory is by design in Python 2.4 and that memory issue also affects every other line of Python code in Civ4.Players who don't do so will no longer be burdened with the wasteful memory use of SmartMap and the visual clutter of scripts they never use.
Until version 2.5 Python's internal small-object allocator never released memory from it's pool of memory arenas.
This was changed from Python 2.5 onwards and it would be possible to port that change back to Python 2.4.
- Patch #1123430: Python's small-object allocator now returns an arena to
the system ``free()`` when all memory within an arena becomes unused
again. Prior to Python 2.5, arenas (256KB chunks of memory) were never
freed. Some applications will see a drop in virtual memory size now,
especially long-running applications that, from time to time, temporarily
use a large number of small objects. Note that when Python returns an
arena to the platform C's ``free()``, there's no guarantee that the
platform C will in turn return that memory to the operating system. The
effect of the patch is to stop making that impossible, and in tests it
appears to be effective at least on Microsoft C and gcc-based systems.
Thanks to Evan Jones for hard work and patience.
Merge the tim-obmalloc branch to the trunk. · python/cpython@cf79aac
This is a heavily altered derivative of SF patch 1123430, Evan Jones's heroic effort to make obmalloc return unused arenas to the system free(), with some heuristic strategies to make it more l...
github.com