I seem to have fixed it. I think the problem was that even though I increased the allotted memory in Twitch it didn't do anything because I wasn't using Twitch to launch it. So I had to increase the allotted memory in the minecraft launcher by changing the 2 to a 4 in the JVM Arguments section of the installation under more options.