Sandboxed Python: memory limits?

Martin v. Loewis martin at
Wed Apr 6 16:38:43 EDT 2011

> I have a vague memory of reading somewhere that it's possible to
> replace the Python memory allocator. This would be an option, if
> there's no simple way to say "your maximum is now 16MB", but I now
> can't find it back. Was I hallucinating?

You can adjust the implementations of PyMem_Malloc and PyObject_Malloc.
This would catch many allocations, but not all of them. If you adjust
PyMem_MALLOC instead of PyMem_Malloc, you catch even more allocations -
but extensions modules which directly call malloc() still would bypass
this accounting.


More information about the Python-list mailing list