It has nothing to do with the amount of ram you have available, but how much of the allocated ram needs to be cleared periodically by Java... This process is what we affectionately know as "Garbage Collection".
Unfortunately Minecraft, although getting better, was written in a less than optimal...