Open the Minecraft Launcher
Go to Installations
Select the profile you want to change
Click More Options
Find JVM Arguments
Edit the `-Xmx` value to the amount of RAM you want
Example: change `-Xmx2G` to `-Xmx4G`
Save the profile
Launch Minecraft
On the Minecraft Launcher, open Installations
Click the three dots on your profile
Choose Edit
Open More Options
Change the `-Xmx` value in JVM Arguments
Save and start the game
If you use a modded launcher, open its settings
Find memory or RAM allocation settings
Increase the allocated RAM amount
Save the settings
Restart Minecraft
Make sure not to allocate more RAM than your computer has available
Close other programs if Minecraft still runs slowly
