[bug or memory issue?] '... took too long to respond.' - After moving and deleting large files

After removing and moving large files I couldn’t reach my server anymore. The error message in the browser was ‘… took too long to respond.’ The error message in the server was:

Out of memory: Kill process 7170 (php-fpm) score 374 or sacrifice child

Then it killed the above process but the server never recovered.
How can I avoid this is the future? Is it really my server running out of memory or is this a bug?

Thanks!