Solved the out of memory issue for the task by cleaning up a lot of code that was exceptionally shitty legacy code.