I played around a little bit with Java's arrays and I realized that a 1GB big byte array needs 4GBs RAM.
That's my code (make sure you have at least 4GB unused RAM or your PC might freeze):
public static void main(String[] args) throws InterruptedException {
Byte[] array = new Byte[1073741823]; // Equals 1GB
System.out.println("Done");
Thread.sleep(10000);
System.out.println("Completely done");
}
That's my machine:
MacBook Pro (64bit; running OS X 10.9 on it)
Java: Java SE 6 (1.6.0_65-b14-462) and Java SE 7 (1.7.0_45).
RAM: 16
Used RAM: about 10GB
When I start this application, it uses 4GB instead of 1. I used these arguments to start that program: -Xmx8g -d64
.