Site is running out of memory causing 500 errors

Some pages on my site are causing a 500 error. Logs say it's because PHP ran out of memory, but increasing memory to 2G still didn't fix the issue.