limiting memory consumption of Python itself or a dict in a Python program

Jonas Maurus jonas.maurus at gmail.com
Wed Sep 19 16:48:33 EDT 2007


Hello everybody,

I'm pondering the following problem:

I want to write a Python program that receives messages via SMTP and
stores them in a dict or an array. For my purposes it would be
important that all received mail would be kept in RAM and not cached
out to disk. If a new message comes in that can't fit in the allocated
memory, a number of old messages would be discarded.

As the server needs to have room for other tasks, I'd like to limit
the overall memory consumption to a certain amount.

Is this possible? How would I go about implementing it? By imposing
"ulimit"s and catching MemoryError?

Thanks for your help,
Jonas




More information about the Python-list mailing list