0

I want to Know how can I make my python program run in such a say that it takes only specified amount of memory (say x bytes) to run, and in case of it requires more memory than x it should be terminated.

I want something like this:

if memory_required > x:
        Terminate program
else:
         Let the program run
9
  • I think you'e just maxing out your system. My OS (macOS) reports (and counting)) 60GB of memory usage for Python. This is probably uncompressed and with swap as my system only has 8GB of real memory but I'm not surprised your system slows down. - Update macOS killed the process to protect itself. Commented Oct 7, 2018 at 12:59
  • What can I do in case I want to terminate this execution? Commented Oct 7, 2018 at 13:02
  • Try Ctrl+D or run 'killall python' in another terminal. Note: the last wil kill every python process running. Commented Oct 7, 2018 at 13:03
  • The problem is that nothing works, python become unfunctional Commented Oct 7, 2018 at 13:04
  • 3
    You just requested at least 16 million terabytes of storage - probably more, depending on how much space list instances take and stuff. What did you expect, then? Do you have that much storage on your machine? If it's still unresponsive, you may have to manually unplug it. Commented Oct 7, 2018 at 13:11

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.