I have Java7 running on 32-bit Windows and 4 GB RAM, but:
java -Xmx4G -Xms4G -jar Minecraft.jar
java -Xmx3G -Xms3G -jar Minecraft.jar
java -Xmx2G -Xms2G -j
This was occuring for me and it is such an easy fix.
if you have installed the correct software and it still occurs than goto
control panel
→ system
→ advanced system settings
for Windows 8 or
control panel
→ system and security
→ system
→ advanced system settings
for Windows 10.
_JAVA_OPTIONS
Variable Value: -Xmx512M
At least that is what worked for me.