Step 1. Open the Minecraft launcher
Step 2. Click Installations
Step 3. Hover over your profile, then click the three dots on the right, then click Edit
Step 4. Click More Options.
Step 5. Under JVM arguments, change -Xmx2G to -Xmx#G
Where # is the amount of RAM you’d like to allocate to Minecraft in gigabytes.
Step 6. Click Save.
You have now allocated more RAM/Memory to Minecraft through the vanilla launcher!