Minecraft can be a ram hungry game depending on your mods and things such as render distance. If you're having trouble running Minecraft properly on your computer, you may need to allocate more ram to Minecraft.
1. Open the Minecraft Launcher and click Installations
2. Next to your Minecraft installation, click the three dots, then Edit
3. Click More Options
4. Scroll to JVM Arguments and change Xmx2G to a different number, such as Xmx4G. This represents how much ram you give to Minecraft. If you have 16GB ram in your PC, we recommend starting with 4-6GB.
5. Click Save and your new configuration will be applied.