Defender Plugin is using all the RAM on my server 3GB

Every time I do a scan with defender it crashes my server. It uses all the RAM (3GB) on my cloud server. Any advise? I get a bad gateway 502 error when I use it.