On Fri, 1 May 2015 03:20 am, Ben Finney wrote: > Jon Ribbens <jon+use...@unequivocal.co.uk> writes: > >> On 2015-04-30, Cecil Westerhof <ce...@decebal.nl> wrote: >> > If I execute: >> > l = range(int(1E9) >> > >> > The python process gobbles up all the memory and is killed. […] Is >> > there a way to circumvent Python claiming all the memory? > > You seem to be asking for a way to stop a program doing exactly what > it's written to do. I don't know what kind of answer you expect.
How about a way to stop a program from doing what you didn't intend it to do? As we all know quite well, computers are quite stupid, they do what they are told, not what we want. It's not just to protect against bugs and mistakes. It's also to protect one user from another user, or a single user from hostile code. Just because Cecil tells the computer "use up 12GB of RAM in one great big list" doesn't mean that the other users of that computer have to acquiesce to that request. >> It's your operating system's job to handle processes. > > Indeed. In this case, the program is written to gobble up memory, and > the operating system kills it. To “circumvent” that behaviour surely > reveals the problem: that the operating system isn't handling processes > very well. Indeed indeed :-) Some programming language virtual machines limit how much memory they will use. The CPython VM isn't one of those, although I understand that both Jython and IronPython are. (I may be wrong -- corrections are welcome.) That means you have to use the OS to limit how much memory CPython will use, if you can. -- Steven -- https://mail.python.org/mailman/listinfo/python-list