First I searched and found two results , one in which it uses C and didn't really understand , the other is just a different question from mine.
Basically I want to shutdown my program when it exceeds a certain limit , for example 1024kb in "memory"