How common are allocation failures
How common are allocation failures
Posted Apr 25, 2026 14:49 UTC (Sat) by devdanzin (subscriber, #183390)In reply to: How common are allocation failures by DemiMarie
Parent article: Using LLMs to find Python C-extension bugs
But in Python it's simple to run into them if your program isn't prepared to, e.g., handle problematic input. A too large string multiplication or an attempt to create a gigantic NumPy array (or even a plain list) will result in a MemoryError that is recoverable and can just result in a log entry or a message to the user.
With very resource starved VMs, you can hit MemoryErrors even in well behaved programs, but they'll probably be gracefully handled by them (including aborting if it makes sense). And as I said elsewhere, it might just make a single request fail and let the program continue running.
I'm gathering a few examples of MemoryErrors in production for another answer here, should be able to post it tonight.
