Out of memory kills uwsgi process

When I’m sending a request from my Django webapplication, I receive a 502 Bad Gateway response.
The syslog of my Ubuntu server contains the following error:
Out of memory: Kill process 4616 (uwsgi) score 351 or sacrifice child
Feb 2 10:18:08 clms kernel: [8035948.756631] Killed process 4616 (uwsgi) total-vm:3452720kB, anon-rss:2953836kB, file-rss:0kB, shmem-rss:124kB

Is there a solution to increase this memory or anything else? Or can this problem also be solved by increasing the server memory?

I’m using uwsgi and nginx

I think your first item to identify is to find out why this is happening.

This is showing nearly 4 GB of memory being used by your application. I would look really carefully at what the application is doing, to see where the memory is being consumed. Unless you know that you’re doing a lot of memory-intensive processing, it shouldn’t be using this much.

You should be able to check your logs to see what the last requests coming in were to give you a starting point where to look.

This amount of memory is used by copying all the records in the database of a company to ZIP-file.
However, I found the solution. I increased the capacity of the server and it worked.
I didn’t create the copy to zip code by my self and it’s only running on a production server so I prefer to not edit the code.