Possible to set cpython heap size?

Chris Mellon arkanes at gmail.com
Thu Feb 22 13:45:31 EST 2007


On 22 Feb 2007 09:52:49 -0800, Andy Watson <aldcwatson at gmail.com> wrote:
>  > Why do you want that? And no, it is not possible. And to be honest:
> I have
> > no idea why e.g. the JVM allows for this.
> >
> > Diez
>
> The reason why is simply that I know roughly how much memory I'm going
> to need, and cpython seems to be taking a fair amount of time
> extending its heap as I read in content incrementally.
>

To my knowledge, no modern OS actually commits any memory at all to a
process until it is written to. Pre-extending the heap would either a)
do nothing, because it'd be essentially a noop, or b) would take at
least long as doing it incrementally (because Python would need to
fill up all that space with objects), without giving you any actual
performance gain when you fill the object space "for real".

In Java, as I understand it, having a fixed size heap allows some
optimizations in the garbage collector. Pythons GC model is different
and, as far as I know, is unlikely to benefit from this.



More information about the Python-list mailing list