Why does 1**2**3**4**5 raise a MemoryError?
d at davea.name
Sun Mar 31 14:43:10 CEST 2013
On 03/31/2013 08:07 AM, morphex wrote:
> Aha, OK. Thought I found a bug but yeah that makes sense ;)
> While we're on the subject, wouldn't it be nice to have some cap there so that it isn't possible to more or less block the system with large exponentiation?
There's an assumption there. The Operating System should defend itself
against starvation by any single process.
Besides, there are many ways for a process to run out of memory, and
exponentiation is probably the least likely of them. In general, an
application cannot tell whether a particular memory allocation will
succeed or not without actually trying the allocation. If it fails, you
get the exception.
I'm typing this while a terminal is open doing the particular operation,
and the system doesn't seem in the least sluggish.
Currently the memory used is at 10gig, and while there are some pauses
in my typing, the system has not died. This is on Linux Ubuntu 12.04.
At 15gig, there are some blockages, of maybe 5 secs each.
More information about the Python-list