Heap out of memory when it shouldn't?

I'm using Eclipse Neon for Ubuntu and I edited eclipse.ini by adding -Xmx8g, so the Heap can take up to 8gb of ram.

However, my application keeps running out of memory around the same point when I used the default value (-Xmx1024). In addition, it's weird that this happens, since by monitoring the applications it seems that Eclipse takes 1.4Gb, while the application 1.3GB, so less than 8GB for sure.

Am I missing something?