{"action":"created","issue":{"url":"https://api.github.com/repos/docker/docker/issues/15020","repository_url":"https://api.github.com/repos/docker/docker","labels_url":"https://api.github.com/repos/docker/docker/issues/15020/labels{/name}","comments_url":"https://api.github.com/repos/docker/docker/issues/15020/comments","events_url":"https://api.github.com/repos/docker/docker/issues/15020/events","html_url":"https://github.com/docker/docker/issues/15020","id":97377313,"number":15020,"title":"growing reported docker container virtual memory size with java processes","user":{"login":"Andrei-Pozolotin","id":1622151,"avatar_url":"https://avatars.githubusercontent.com/u/1622151?v=3","gravatar_id":"","url":"https://api.github.com/users/Andrei-Pozolotin","html_url":"https://github.com/Andrei-Pozolotin","followers_url":"https://api.github.com/users/Andrei-Pozolotin/followers","following_url":"https://api.github.com/users/Andrei-Pozolotin/following{/other_user}","gists_url":"https://api.github.com/users/Andrei-Pozolotin/gists{/gist_id}","starred_url":"https://api.github.com/users/Andrei-Pozolotin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Andrei-Pozolotin/subscriptions","organizations_url":"https://api.github.com/users/Andrei-Pozolotin/orgs","repos_url":"https://api.github.com/users/Andrei-Pozolotin/repos","events_url":"https://api.github.com/users/Andrei-Pozolotin/events{/privacy}","received_events_url":"https://api.github.com/users/Andrei-Pozolotin/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/docker/docker/labels/kind/bug","name":"kind/bug","color":"FF8C94"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":13,"created_at":"2015-07-27T03:23:14Z","updated_at":"2016-04-19T18:48:07Z","closed_at":null,"body":"1) in various multiple different containers running java, ```top/htop``` tools report VIRT (virtual) memory \r\nas order of magnitude greater then the physical memory of RES (resident) process memory\r\n\r\n2) processes seem to run fine for several days (did not test longer), while VIRT keeps going up and RES stays fixed (as configured by java startup parameters setting process memory limits)\r\n\r\n3) each GC (garbage collection) request to the JVM increases reported VIRT value\r\n\r\n4) java 8 GC type is \"G1\"\r\n\r\n5) same applications with same o/s, same settings, etc - do no exhibit such behavior when run on the host\r\n\r\nexample: total physical ram 16G, java process resident ram 1.6G, reported virtual size 80G and growing\r\n\r\n**top/htop report:**\r\n\r\n![image](https://cloud.githubusercontent.com/assets/1622151/8897868/e39891c8-33e1-11e5-99d9-1aace8870ea0.png)\r\n\r\n**docker stats report:** for the same procesess\r\n![image](https://cloud.githubusercontent.com/assets/1622151/8897876/11df0a26-33e2-11e5-9102-c1d72e3b28a3.png)\r\n\r\n```\r\nuname -a\r\nLinux wks002 3.13.0-58-generic #97-Ubuntu SMP Wed Jul 8 02:56:15 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux\r\n```\r\n\r\n```\r\njava -version\r\njava version \"1.8.0_45\"\r\nJava(TM) SE Runtime Environment (build 1.8.0_45-b14)\r\nJava HotSpot(TM) 64-Bit Server VM (build 25.45-b02, mixed mode)\r\n```\r\n\r\n```\r\ndocker info\r\nContainers: 3\r\nImages: 248\r\nStorage Driver: aufs\r\n Root Dir: /var/lib/docker/aufs\r\n Backing Filesystem: extfs\r\n Dirs: 254\r\n Dirperm1 Supported: false\r\nExecution Driver: native-0.2\r\nLogging Driver: json-file\r\nKernel Version: 3.13.0-58-generic\r\nOperating System: Ubuntu 14.04.2 LTS\r\nCPUs: 8\r\nTotal Memory: 15.62 GiB\r\nName: wks002\r\nID: 65Y6:OAEC:KGES:X3NV:LMEH:CL5X:6XLV:WKZ3:52CB:I6AJ:J4Y4:HLM3\r\nWARNING: No swap limit support\r\n```\r\n\r\n```\r\ndocker --version\r\nDocker version 1.7.1, build 786b29d\r\n```\r\n\r\nseries of images:\r\nhttps://registry.hub.docker.com/u/carrotgarden/zinc/dockerfile/\r\nhttps://registry.hub.docker.com/u/carrotgarden/java-service/dockerfile/\r\nhttps://registry.hub.docker.com/u/carrotgarden/java-build/dockerfile/\r\nhttps://registry.hub.docker.com/u/carrotgarden/java-8/dockerfile/\r\nhttps://registry.hub.docker.com/u/carrotgarden/ubuntu/dockerfile/\r\n\r\ntypical container invocation command:\r\n```\r\n# container\r\nNAME=$(basename $DIR)\r\n\r\n# docker image\r\nIMAGE=\"carrotgarden/$NAME\"\r\n\r\ndocker run \\\r\n    --rm \\\r\n    --net=host \\\r\n    --pid=host \\\r\n    --env HOME \\\r\n    --env DISPLAY \\\r\n    --env TERM=xterm \\\r\n    --env NO_AT_BRIDGE=1 \\\r\n    --user $USER \\\r\n    --device=/dev/dri \\\r\n    --device=/dev/snd \\\r\n    --device=/dev/video0 \\\r\n    --volume=/etc/group:/etc/group:ro \\\r\n    --volume=/etc/passwd:/etc/passwd:ro \\\r\n    --volume=/home:/home \\\r\n    --volume=/tmp:/tmp \\\r\n    --name=$NAME \\\r\n    $IMAGE &\r\n```\r\n\r\ntypical java execution parameters:\r\nhttps://registry.hub.docker.com/u/carrotgarden/zinc/dockerfile/\r\n```\r\nENV ZINC_COMMAND=\" \\\r\n    java \\\r\n    -server \\\r\n    -XX:+UseG1GC \\\r\n    -XX:+DoEscapeAnalysis \\\r\n    -XX:+UseCompressedOops \\\r\n    -XX:+UseCompressedClassPointers \\\r\n    -XX:+HeapDumpOnOutOfMemoryError \\\r\n    -XX:InitialHeapSize=$JAVA_HEAP \\\r\n    -XX:MaxHeapSize=$JAVA_HEAP \\\r\n    -XX:ThreadStackSize=$JAVA_STACK \\\r\n    -XX:MetaspaceSize=$JAVA_META \\\r\n    -XX:MaxMetaspaceSize=$JAVA_META \\\r\n    -XX:InitialCodeCacheSize=$JAVA_CODE \\\r\n    -XX:ReservedCodeCacheSize=$JAVA_CODE \\\r\n    -Dzinc.home=$ZINC_FOLDER \\\r\n    -classpath $ZINC_FOLDER/lib/*:. \\\r\n    com.typesafe.zinc.Nailgun \\\r\n    $ZINC_PORT $ZINC_TIMEOUT \\\r\n\"\r\n```"},"comment":{"url":"https://api.github.com/repos/docker/docker/issues/comments/212065470","html_url":"https://github.com/docker/docker/issues/15020#issuecomment-212065470","issue_url":"https://api.github.com/repos/docker/docker/issues/15020","id":212065470,"user":{"login":"cpuguy83","id":799078,"avatar_url":"https://avatars.githubusercontent.com/u/799078?v=3","gravatar_id":"","url":"https://api.github.com/users/cpuguy83","html_url":"https://github.com/cpuguy83","followers_url":"https://api.github.com/users/cpuguy83/followers","following_url":"https://api.github.com/users/cpuguy83/following{/other_user}","gists_url":"https://api.github.com/users/cpuguy83/gists{/gist_id}","starred_url":"https://api.github.com/users/cpuguy83/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cpuguy83/subscriptions","organizations_url":"https://api.github.com/users/cpuguy83/orgs","repos_url":"https://api.github.com/users/cpuguy83/repos","events_url":"https://api.github.com/users/cpuguy83/events{/privacy}","received_events_url":"https://api.github.com/users/cpuguy83/received_events","type":"User","site_admin":false},"created_at":"2016-04-19T18:48:07Z","updated_at":"2016-04-19T18:48:07Z","body":"It would be interesting to see the output of [pmap](http://linux.die.net/man/1/pmap)\r\nAlso a quick search on java virt mem usage brings me to tweaking `MALLOC_ARENA_MAX`, seems to be an issue with glibc >= 2.1\r\n\r\nThis is not likely to be a Docker issue but rather a misconfiguration, perhaps even something set up in \"normal\" environments (like in an init script) that is missing in the container."}}