#StackBounty: #ram #memory-usage Why buf/cache take so much ram and do not chunk

Bounty: 100

So I just installed my new Ubuntu 16.04 with all necessary stuff to start programing. But now I have big problem with ram. I can not open more application that I have on my previous notebook with linux 12.04 which has half of my current memory.
My 1 problem is with process XORG:

 1040 root      20   0 2403428 1,091g 1,014g S  21,9  7,1 247:35.70 Xorg                                                                                                                   

it take so much ram after one day of using my notebook.
Second problem is with buff/cache which always take over 2gb. I read this and they declare that this should chunk when my system need it.
So my current state is:

KiB Mem : 16063252 total,  2044612 free, 11033624 used,  2985016 buff/cache
KiB Swap:        0 total,        0 free,        0 used.  2778236 avail Mem 

So I have still like 2GB free.

now I start compile one of my bigger project. When free is close to 0 then compile process crash because it has no free ram:

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.16:test (surefire-itest) on project my-project: Execution surefire-itest of goal org.apache.maven.plugins:maven-surefire-plugin:2.16:test failed: The forked VM terminated without saying properly goodbye. VM crash or System.exit called ?
[ERROR] Command was/bin/sh -c cd /my-project && /usr/lib/jvm/java-8-oracle/jre/bin/java -Dfile.encoding=UTF-8 -jar my-project/target/surefire/surefirebooter8879869524337464183.jar my-project/target/surefire/surefire5896025025928619492tmp my-project/target/surefire/surefire_21839336642879397359tmp

this is state couple of second before crash:

KiB Mem : 16063252 total,   178808 free, 13693208 used,  2191236 buff/cache
KiB Swap:        0 total,        0 free,        0 used.   191788 avail Mem 

yes free and avail memory is close to 0 but there is still like 2 GB in buff/cache. Why linux/java is not using this memory ? Is there some way how I can optimized my current memory usage ?

Get this bounty!!!

Leave a Reply