{"id":339272,"date":"2022-10-04T09:00:06","date_gmt":"2022-10-04T09:00:06","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=339272"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=339272","title":{"rendered":"<span>\u041d\u0430\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u0435\u043c \u043f\u0430\u043c\u044f\u0442\u044c JVM-\u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0432 Kubernetes<\/span>"},"content":{"rendered":"<div><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w780q1\/getpro\/habr\/upload_files\/872\/1e5\/303\/8721e5303b173b537edd50d4cbe3d2bd.jpg\" width=\"700\" height=\"467\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/872\/1e5\/303\/8721e5303b173b537edd50d4cbe3d2bd.jpg\" data-blurred=\"true\"\/><figcaption><\/figcaption><\/figure>\n<p>\u0414\u0440\u0443\u0437\u044c\u044f, \u0432\u0441\u0435\u043c \u043f\u0440\u0438\u0432\u0435\u0442! \u041a\u0430\u043a \u0438\u0437\u0432\u0435\u0441\u0442\u043d\u043e, \u0432 Kubernetes \u0443 \u043a\u0430\u0436\u0434\u043e\u0433\u043e pod\u2019\u0430 \u0435\u0441\u0442\u044c \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u0435 \u043d\u0430\u00a0 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u043f\u0430\u043c\u044f\u0442\u0438 (<code>limits.memory<\/code>), \u0438, \u043a\u0430\u043a \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442 \u043e\u043f\u044b\u0442, \u0434\u0430\u043b\u0435\u043a\u043e \u043d\u0435 \u0432\u0441\u0435\u0433\u0434\u0430 \u043e\u0447\u0435\u0432\u0438\u0434\u043d\u043e, \u043a\u0430\u043a JVM-\u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0438\u043d\u0442\u0435\u0440\u043f\u0440\u0435\u0442\u0438\u0440\u0443\u0435\u0442 \u044d\u0442\u0443 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0443, \u0447\u0442\u043e \u043f\u043e\u0440\u043e\u0439 \u043c\u043e\u0436\u0435\u0442 \u043f\u0440\u0438\u0432\u043e\u0434\u0438\u0442\u044c \u043a OOMKill.<\/p>\n<p>\u042f \u0445\u043e\u0442\u0435\u043b \u0431\u044b \u043f\u043e\u0434\u0435\u043b\u0438\u0442\u044c\u0441\u044f \u043e\u0434\u043d\u0438\u043c \u0438\u0437 \u0441\u043f\u043e\u0441\u043e\u0431\u043e\u0432 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438 \u043f\u0430\u043c\u044f\u0442\u0438 \u0434\u043b\u044f Java-\u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0439 \u0432 Kubernetes. \u0421\u0440\u0430\u0437\u0443 \u0441\u043a\u0430\u0436\u0443, \u0447\u0442\u043e \u0438\u0442\u043e\u0433\u043e\u0432\u044b\u0435 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438, \u043a \u043a\u043e\u0442\u043e\u0440\u044b\u043c \u043c\u044b \u043f\u0440\u0438\u0434\u0451\u043c, \u0431\u0443\u0434\u0443\u0442 \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043d\u044b \u043b\u0438\u0448\u044c \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043f\u0440\u0438\u043c\u0435\u0440\u0430 \u0438 \u0434\u043e\u043b\u0436\u043d\u044b \u043d\u0430\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u0442\u044c\u0441\u044f \u0438\u043d\u0434\u0438\u0432\u0438\u0434\u0443\u0430\u043b\u044c\u043d\u043e \u043f\u043e\u0434 \u043a\u0430\u0436\u0434\u043e\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435. \u0420\u0430\u0441\u0441\u043c\u0430\u0442\u0440\u0438\u0432\u0430\u0442\u044c \u0431\u0443\u0434\u0435\u043c \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438 \u0438 \u043c\u0435\u0442\u0440\u0438\u043a\u0438 \u043e\u0431\u044b\u0447\u043d\u043e\u0433\u043e \u043c\u0438\u043a\u0440\u043e\u0441\u0435\u0440\u0432\u0438\u0441\u0430 \u043d\u0430 Spring boot, \u0438\u043d\u0442\u0435\u0433\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0433\u043e \u0441\u043e Spring Boot Admin (\u0434\u0430\u043b\u0435\u0435 \u043f\u0440\u043e\u0441\u0442\u043e SBA).<\/p>\n<p>\u0414\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u043e\u0441\u0432\u0435\u0436\u0438\u043c \u0442\u0435\u043e\u0440\u0438\u044e \u043f\u043e \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u0443 \u043f\u0430\u043c\u044f\u0442\u0438 \u0432 Java. \u0412\u043a\u0440\u0430\u0442\u0446\u0435, \u0433\u043b\u043e\u0431\u0430\u043b\u044c\u043d\u043e \u043f\u0430\u043c\u044f\u0442\u044c \u0434\u0435\u043b\u0438\u0442\u0441\u044f \u043d\u0430 \u0434\u0432\u0430 \u0440\u0430\u0437\u0434\u0435\u043b\u0430, <strong>\u0443\u043f\u0440\u043e\u0449\u0435\u043d\u043d\u043e<\/strong>:<\/p>\n<ul>\n<li>\n<p>Heap. \u042d\u0442\u043e\u0442 \u0440\u0430\u0437\u0434\u0435\u043b \u0434\u0435\u043b\u0438\u0442\u0441\u044f \u043d\u0430 \u043f\u043e\u0434\u0440\u0430\u0437\u0434\u0435\u043b\u044b:<\/p>\n<ul>\n<li>\n<p>Eden \u2014 \u0434\u043b\u044f \u0432\u043d\u043e\u0432\u044c \u0441\u043e\u0437\u0434\u0430\u043d\u043d\u044b\u0445 \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432, \u0447\u0438\u0441\u0442\u0438\u0442\u0441\u044f \u043f\u0440\u0438 \u043a\u0430\u0436\u0434\u043e\u0439 \u0441\u0431\u043e\u0440\u043a\u0435 \u043c\u0443\u0441\u043e\u0440\u0430 (Minor GC).<\/p>\n<\/li>\n<li>\n<p>Survivor \u2014 \u0434\u043b\u044f \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432, \u043f\u0435\u0440\u0435\u0436\u0438\u0432\u0448\u0438\u0445 Minor GC.<\/p>\n<\/li>\n<li>\n<p>Tenured \u2014 \u0434\u043b\u044f \u0434\u043e\u043b\u0433\u043e\u0436\u0438\u0432\u0443\u0449\u0438\u0445 \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432, \u0447\u0438\u0441\u0442\u0438\u0442\u0441\u044f \u043f\u0440\u0438 Major GC.<\/p>\n<\/li>\n<\/ul>\n<\/li>\n<li>\n<p>Non-heap. \u0421\u043e\u0441\u0442\u043e\u0438\u0442 \u0438\u0437:<\/p>\n<ul>\n<li>\n<p>Metaspace (\u0438 \u0432 \u0441\u043e\u0441\u0442\u0430\u0432\u0435 \u043d\u0435\u0433\u043e Compressed Class Space) \u2014 \u043c\u0435\u0442\u0430\u0434\u0430\u043d\u043d\u044b\u0435 \u0437\u0430\u0433\u0440\u0443\u0436\u0435\u043d\u043d\u044b\u0445 \u043a\u043b\u0430\u0441\u0441\u043e\u0432<\/p>\n<\/li>\n<li>\n<p>Code Cache \u2014 \u0434\u043b\u044f \u0441\u043a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0433\u043e JIT-\u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440\u043e\u043c<\/p>\n<\/li>\n<li>\n<p>ThreadStackArea<\/p>\n<\/li>\n<li>\n<p>Direct buffers<\/p>\n<\/li>\n<li>\n<p>Garbage collection<\/p>\n<\/li>\n<li>\n<p>Symbol tables \u0438 \u043f\u0440\u043e\u0447\u0438\u0435, \u043d\u0430 \u0447\u0435\u043c \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u043e \u043e\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0442\u044c\u0441\u044f \u043d\u0435 \u0431\u0443\u0434\u0435\u043c<\/p>\n<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<p>\u0418\u0442\u043e\u0433\u043e:<\/p>\n<p>Heap (Eden, Survivor, Tenured) + Non-heap (Metaspace + Code Cache + Thread stack area + Direct buffers + Symbol tables + Other JVM structures)<\/p>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c, \u043a\u0430\u043a \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 c \u043f\u0430\u043c\u044f\u0442\u044c\u044e \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u043d\u0430 Spring Boot \u0431\u0435\u0437 \u043a\u0430\u043a\u043e\u0439-\u043b\u0438\u0431\u043e \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438 \u043f\u0430\u043c\u044f\u0442\u0438, \u0437\u0430\u0434\u0430\u0432 memory.limits \u0432 \u041aubernetes \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 1280 \u041c\u0431.\u00a0<\/p>\n<p>\u0415\u0441\u043b\u0438 \u043d\u0430\u0441\u0442\u0440\u043e\u0435\u043d Native memory tracking (NMT), \u0442\u043e \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u0443\u044e \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u043a\u043e\u043c\u0430\u043d\u0434\u043e\u0439 <code>jcmd 1 VM.native_memory<\/code>.<\/p>\n<details class=\"spoiler\">\n<summary>Native Memory Tracking<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"java\">Total: reserved=2014514KB, committed=626614KB -                 Java Heap (reserved=327680KB, committed=259652KB)                             (mmap: reserved=327680KB, committed=259652KB)    -                     Class (reserved=1229865KB, committed=205737KB)                             (classes #36029)                             (  instance classes #33803, array classes #2226)                             (malloc=7209KB #105907)                              (mmap: reserved=1222656KB, committed=198528KB)                              (  Metadata:   )                             (    reserved=174080KB, committed=173568KB)                             (    used=169946KB)                             (    free=3622KB)                             (    waste=0KB =0.00%)                             (  Class space:)                             (    reserved=1048576KB, committed=24960KB)                             (    used=22922KB)                             (    free=2038KB)                             (    waste=0KB =0.00%)   -                    Thread (reserved=134801KB, committed=10461KB)                             (thread #82)                             (stack: reserved=134408KB, committed=10068KB)                             (malloc=296KB #494)                              (arena=97KB #163)   -                      Code (reserved=251808KB, committed=80620KB)                             (malloc=4120KB #15476)                              (mmap: reserved=247688KB, committed=76500KB)    -                        GC (reserved=2219KB, committed=2003KB)                             (malloc=1147KB #4677)                              (mmap: reserved=1072KB, committed=856KB)    -                  Compiler (reserved=907KB, committed=907KB)                             (malloc=777KB #1701)                              (arena=131KB #5)   -                  Internal (reserved=9479KB, committed=9479KB)                             (malloc=9479KB #19066)    -                     Other (reserved=4154KB, committed=4154KB)                             (malloc=4154KB #191)    -                    Symbol (reserved=40259KB, committed=40259KB)                             (malloc=33634KB #418136)                              (arena=6624KB #1)   -    Native Memory Tracking (reserved=9068KB, committed=9068KB)                             (malloc=32KB #432)                              (tracking overhead=9035KB)   -               Arena Chunk (reserved=2484KB, committed=2484KB)                             (malloc=2484KB)    -                   Logging (reserved=4KB, committed=4KB)                             (malloc=4KB #189)    -                 Arguments (reserved=31KB, committed=31KB)                             (malloc=31KB #498)    -                    Module (reserved=1158KB, committed=1158KB)                             (malloc=1158KB #6305)    -              Synchronizer (reserved=558KB, committed=558KB)                             (malloc=558KB #4724)    -                 Safepoint (reserved=8KB, committed=8KB)                             (mmap: reserved=8KB, committed=8KB)    -                   Unknown (reserved=32KB, committed=32KB)                             (mmap: reserved=32KB, committed=32KB) <\/code><\/pre>\n<\/p>\n<\/div>\n<\/details>\n<p>SBA:<\/p>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043d\u0430 \u0434\u0430\u043d\u043d\u044b\u0435 \u0438\u0437 \u0430\u0434\u043c\u0438\u043d\u043a\u0438:<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/4fc\/c05\/703\/4fcc057034d30f68ffe804e974e0d4b2.png\" width=\"1600\" height=\"387\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/4fc\/c05\/703\/4fcc057034d30f68ffe804e974e0d4b2.png\"\/><figcaption><\/figcaption><\/figure>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/d53\/d00\/abb\/d53d00abb8491aa81495a6f8cc6356f1.png\" width=\"1600\" height=\"588\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/d53\/d00\/abb\/d53d00abb8491aa81495a6f8cc6356f1.png\"\/><figcaption><\/figcaption><\/figure>\n<p>\u0412\u0438\u0434\u043d\u043e, \u0447\u0442\u043e \u0434\u043b\u044f Heap \u0432\u044b\u0434\u0435\u043b\u0435\u043d\u043e \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e \u0432\u0441\u0435\u0433\u043e 324 \u041c\u0431 \u0438 \u0434\u043b\u044f Non-heap 1,33 \u0413\u0431,\u043f\u0440\u0438 \u0442\u043e\u043c \u0447\u0442\u043e \u043f\u0430\u043c\u044f\u0442\u0438 \u043d\u0430 pod \u0431\u044b\u043b\u043e \u0432\u044b\u0434\u0435\u043b\u0435\u043d\u043e \u0432\u0441\u0435\u0433\u043e 1280 \u041c\u0431. \u0415\u0441\u043b\u0438 \u0441\u043b\u043e\u0436\u0438\u0442\u044c \u0440\u0430\u0437\u043c\u0435\u0440\u044b Heap \u0438 Non-heap, \u0442\u043e \u0432\u0438\u0434\u043d\u043e, \u0447\u0442\u043e \u043e\u0431\u044a\u0451\u043c \u043f\u0430\u043c\u044f\u0442\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0433\u043e\u0442\u043e\u0432\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435, \u0432\u044b\u0445\u043e\u0434\u0438\u0442 \u0434\u0430\u043b\u0435\u043a\u043e \u0437\u0430 \u043f\u0440\u0435\u0434\u0435\u043b\u044b \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u044f \u0434\u043b\u044f \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u0430. \u0427\u0442\u043e \u0436, OOMKill \u043d\u0430\u043c \u043e\u0431\u0435\u0441\u043f\u0435\u0447\u0435\u043d \ud83d\ude42<\/p>\n<p>\u041f\u043e\u043f\u0440\u043e\u0431\u0443\u0435\u043c \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u043d\u0430\u0441\u0442\u0440\u043e\u0438\u0442\u044c \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435. \u041f\u0440\u0438 \u044d\u0442\u043e\u043c \u0441\u0442\u043e\u0438\u0442 \u043f\u043e\u043c\u043d\u0438\u0442\u044c, \u0447\u0442\u043e \u0443 \u043d\u0430\u0441 \u0434\u043b\u044f \u0440\u0430\u0437\u043d\u044b\u0445 \u0441\u0442\u0435\u043d\u0434\u043e\u0432 (QA, stage, prod) \u043c\u043e\u0433\u0443\u0442 \u0442\u0440\u0435\u0431\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0435 \u043e\u0431\u044a\u0451\u043c\u044b \u043f\u0430\u043c\u044f\u0442\u0438. \u0414\u043b\u044f \u0441\u0431\u043e\u0440\u043a\u0438 \u043e\u0431\u0440\u0430\u0437\u043e\u0432 \u043c\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0443 <a href=\"https:\/\/github.com\/GoogleContainerTools\/jib\"><u>JIB<\/u><\/a>, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0443\u0434\u043e\u0431\u043d\u043e \u043d\u0430\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u0442\u044c \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u0437\u0430\u043f\u0443\u0441\u043a\u0430 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0432 entry.sh.<\/p>\n<p>\u041d\u0430\u0448\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u0442\u0441\u044f \u0432 Docker \u043f\u043e \u043a\u043e\u043c\u0430\u043d\u0434\u0435:<\/p>\n<pre><code class=\"java\">java \\ -Xms${HEAP_SIZE_MB}M \\ -Xmx${HEAP_SIZE_MB}M \\ -Xss1M \\ -XX:MaxMetaspaceSize=${METASPACE_SIZE_MB}M \\ -XX:CompressedClassSpaceSize=${COMPRESSED_CLASS_SPACE_SIZE_MB}M \\ -XX:ReservedCodeCacheSize=${RESERVED_CODE_CACHE_SIZE_MB}M \\ -XX:MaxDirectMemorySize=${DIRECT_MEMORY_SIZE_MB}M \\ -XX:NativeMemoryTracking=summary \\ -cp \"\/app\/resources:\/app\/classes:\/app\/libs\/*\" ru.example.application.DemoApplication<\/code><\/pre>\n<p>\u0422\u0443\u0442 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438 Heap \u0438 Non-heap \u0440\u0430\u0441\u043f\u0438\u0441\u0430\u043d\u044b \u043f\u043e \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438. \u041f\u043e\u043f\u0440\u043e\u0431\u0443\u0435\u043c \u0440\u0430\u0437\u043e\u0431\u0440\u0430\u0442\u044c\u0441\u044f. \u041d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438 Heap:<\/p>\n<pre><code class=\"java\">-Xms${HEAP_SIZE_MB}M \\ -Xmx${HEAP_SIZE_MB}M \\<\/code><\/pre>\n<p>\u00a0\u041d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438 Non-heap:<\/p>\n<pre><code class=\"java\">-Xss1M \\ -XX:MaxMetaspaceSize=${METASPACE_SIZE_MB}M \\ -XX:CompressedClassSpaceSize=${COMPRESSED_CLASS_SPACE_SIZE_MB}M \\ -XX:ReservedCodeCacheSize=${RESERVED_CODE_CACHE_SIZE_MB}M \\ -XX:MaxDirectMemorySize=${DIRECT_MEMORY_SIZE_MB}M \\<\/code><\/pre>\n<p>\u042d\u0442\u0438 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435 \u043c\u043e\u0436\u043d\u043e \u0432\u044b\u0441\u0447\u0438\u0442\u0430\u0442\u044c \u043f\u0440\u0438 \u0437\u0430\u043f\u0443\u0441\u043a\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0432 entry.sh, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 \u043f\u043e \u0444\u043e\u0440\u043c\u0443\u043b\u0435 (\u043f\u0440\u0438\u043c\u0435\u0440\u043d\u043e\u0439):<\/p>\n<pre><code class=\"java\">#Converting a pod memory limit from bytes to megabytes POD_MEM_LIMIT_MB=`expr $POD_MEM_LIMIT \/ 1024 \/ 1024`   #Calculating the metaspace size METASPACE_SIZE_MB=`expr $POD_MEM_LIMIT_MB \/ 5`   #Calculating the compressed class space size COMPRESSED_CLASS_SPACE_SIZE_MB=`expr $METASPACE_SIZE_MB \/ 5`   #Calculating the reserved code cache size #(not a part of the metaspace but it is easier to get it relatively) RESERVED_CODE_CACHE_SIZE_MB=`expr $METASPACE_SIZE_MB \/ 3` echo \"RESERVED_CODE_CACHE_SIZE_MB=\"$RESERVED_CODE_CACHE_SIZE_MB   #Calculating the reserved code cache size DIRECT_MEMORY_SIZE_MB=`expr $METASPACE_SIZE_MB \/ 16` echo \"DIRECT_MEMORY_SIZE_MB=\"$DIRECT_MEMORY_SIZE_MB   #Calculating the reserved system usage and other purposes OTHER_USAGE_MB=`expr $POD_MEM_LIMIT_MB \/ 4`   #Calculating total non heap size NON_HEAP_SIZE_MB=`expr $METASPACE_SIZE_MB + $RESERVED_CODE_CACHE_SIZE_MB + $DIRECT_MEMORY_SIZE_MB + $OTHER_USAGE_MB`   #Calculating the heap size HEAP_SIZE_MB=`expr $POD_MEM_LIMIT_MB - $NON_HEAP_SIZE_MB`<\/code><\/pre>\n<p>\u0420\u0430\u0437\u043c\u0435\u0440 Metaspace, \u043a\u0430\u043a \u0438 \u0434\u0440\u0443\u0433\u0438\u0445 \u0441\u0435\u0433\u043c\u0435\u043d\u0442\u043e\u0432, \u043c\u043e\u0436\u043d\u043e \u0443\u043a\u0430\u0437\u0430\u0442\u044c \u0438 \u0444\u0438\u043a\u0441\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u043c, \u043d\u043e \u0434\u043b\u044f \u043f\u0440\u0438\u043c\u0435\u0440\u0430 \u043e\u0441\u0442\u0430\u0432\u0438\u043c \u0432\u044b\u0447\u0438\u0441\u043b\u044f\u0435\u043c\u044b\u043c.<\/p>\n<p>\u0418 \u043f\u043e\u0441\u043b\u0435 \u0442\u0430\u043a\u043e\u0439 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438 \u0441\u043d\u043e\u0432\u0430 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u043c<code>jcmd 1 VM.native_memory<\/code> \u0438 \u043a\u0430\u0440\u0442\u0438\u043d\u0430 \u0432\u0438\u0434\u0438\u0442\u0441\u044f \u0443\u0436\u0435 \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u0438\u043d\u043e\u0439:<\/p>\n<details class=\"spoiler\">\n<summary>\u041f\u043e\u0434\u0440\u043e\u0431\u043d\u0435\u0435<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"java\">Total: reserved=1109330KB, committed=961126KB -                 Java Heap (reserved=618496KB, committed=618496KB)                             (mmap: reserved=618496KB, committed=618496KB)    -                     Class (reserved=230915KB, committed=202995KB)                             (classes #35923)                             (  instance classes #33695, array classes #2228)                             (malloc=6659KB #96909)                              (mmap: reserved=224256KB, committed=196336KB)                              (  Metadata:   )                             (    reserved=172032KB, committed=171512KB)                             (    used=167998KB)                             (    free=3514KB)                             (    waste=0KB =0.00%)                             (  Class space:)                             (    reserved=52224KB, committed=24824KB)                             (    used=22857KB)                             (    free=1967KB)                             (    waste=0KB =0.00%)   -                    Thread (reserved=98449KB, committed=10349KB)                             (thread #82)                             (stack: reserved=98056KB, committed=9956KB)                             (malloc=296KB #494)                              (arena=97KB #163)   -                      Code (reserved=91279KB, committed=59095KB)                             (malloc=3559KB #14025)                              (mmap: reserved=87720KB, committed=55536KB)    -                        GC (reserved=3134KB, committed=3134KB)                             (malloc=1114KB #4516)                              (mmap: reserved=2020KB, committed=2020KB)    -                  Compiler (reserved=665KB, committed=665KB)                             (malloc=534KB #1752)                              (arena=131KB #5)   -                  Internal (reserved=8429KB, committed=8429KB)                             (malloc=8429KB #16669)    -                     Other (reserved=4792KB, committed=4792KB)                             (malloc=4792KB #149)    -                    Symbol (reserved=40213KB, committed=40213KB)                             (malloc=33588KB #415272)                              (arena=6624KB #1)   -    Native Memory Tracking (reserved=8808KB, committed=8808KB)                             (malloc=27KB #341)                              (tracking overhead=8782KB)   -               Arena Chunk (reserved=2419KB, committed=2419KB)                             (malloc=2419KB)    -                   Logging (reserved=4KB, committed=4KB)                             (malloc=4KB #189)    -                 Arguments (reserved=31KB, committed=31KB)                             (malloc=31KB #498)    -                    Module (reserved=1114KB, committed=1114KB)                             (malloc=1114KB #6172)    -              Synchronizer (reserved=543KB, committed=543KB)                             (malloc=543KB #4597)    -                 Safepoint (reserved=8KB, committed=8KB)                             (mmap: reserved=8KB, committed=8KB)    -                   Unknown (reserved=32KB, committed=32KB)                             (mmap: reserved=32KB, committed=32KB) <\/code><\/pre>\n<\/p>\n<\/div>\n<\/details>\n<p>SBA:<\/p>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043d\u0430 \u0434\u0430\u043d\u043d\u044b\u0435 \u0438\u0437 \u0430\u0434\u043c\u0438\u043d\u043a\u0438:<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/f58\/df5\/7f2\/f58df57f2aaee56bb942cec891a72be7.png\" width=\"1600\" height=\"383\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/f58\/df5\/7f2\/f58df57f2aaee56bb942cec891a72be7.png\"\/><figcaption><\/figcaption><\/figure>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/aa0\/048\/0ce\/aa00480ce0e8f28eca14affba4523485.png\" width=\"1600\" height=\"588\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/aa0\/048\/0ce\/aa00480ce0e8f28eca14affba4523485.png\"\/><figcaption><\/figcaption><\/figure>\n<p>\u0415\u0441\u043b\u0438 \u0442\u0435\u043f\u0435\u0440\u044c \u0441\u043b\u043e\u0436\u0438\u0442\u044c \u0440\u0430\u0437\u043c\u0435\u0440\u044b \u0441\u0435\u0433\u043c\u0435\u043d\u0442\u043e\u0432, \u0442\u043e \u0442\u0435\u043f\u0435\u0440\u044c \u0443 \u043d\u0430\u0441 \u0432\u0441\u0435 \u043f\u0440\u0435\u0434\u0435\u043b\u044c\u043d\u044b\u0435 \u0440\u0430\u0437\u043c\u0435\u0440\u044b Heap+Non-heap<em> <\/em>\u043d\u0438\u0436\u0435, \u0447\u0435\u043c \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u0435 \u043f\u0430\u043c\u044f\u0442\u0438 pod\u2019\u0430 \u0438 \u0435\u0441\u0442\u044c \u0437\u0430\u043f\u0430\u0441 \u043d\u0430 \u043f\u0440\u043e\u0447\u0438\u0435 \u0440\u0430\u0441\u0445\u043e\u0434\u044b.<\/p>\n<h3>\u0418\u0442\u043e\u0433\u0438<\/h3>\n<p>\u041f\u0440\u043e\u0446\u0435\u0441\u0441 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438 \u043f\u0430\u043c\u044f\u0442\u0438 \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u043d\u0435\u043f\u0440\u043e\u0441\u0442\u043e\u0439 \u0438 \u0442\u0440\u0435\u0431\u0443\u0435\u0442 \u0443\u0447\u0451\u0442\u0430 \u043c\u043d\u043e\u0433\u0438\u0445 \u043c\u0435\u043b\u043a\u0438\u0445 \u0438 \u043a\u0440\u0443\u043f\u043d\u044b\u0445 \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u043e\u0441\u0442\u0435\u0439 \u0438 \u0444\u0430\u043a\u0442\u043e\u0440\u043e\u0432, \u043c\u043d\u043e\u0433\u0438\u0435 \u0438\u0437 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043d\u0435 \u0431\u044b\u043b\u0438 \u0443\u043f\u043e\u043c\u044f\u043d\u0443\u0442\u044b \u0432 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435. \u041c\u044b \u043f\u0440\u043e\u0448\u043b\u0438\u0441\u044c \u043f\u043e \u0431\u0430\u0437\u043e\u0432\u044b\u043c \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430\u043c \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438 \u043f\u0430\u043c\u044f\u0442\u0438 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f, \u0430 \u0442\u0430\u043a\u0436\u0435 \u043f\u043e \u043e\u0434\u043d\u043e\u043c\u0443 \u0438\u0437 \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u043e\u0432 \u0434\u0438\u0430\u0433\u043d\u043e\u0441\u0442\u0438\u043a\u0438, \u043f\u0440\u0438 \u044d\u0442\u043e\u043c, \u0441\u0442\u043e\u0438\u0442 \u043f\u043e\u043c\u043d\u0438\u0442\u044c, \u0447\u0442\u043e \u043f\u0440\u0438\u0432\u0435\u0434\u0451\u043d\u043d\u044b\u0435 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438 \u043d\u043e\u0441\u044f\u0442 <strong>\u043f\u0440\u0438\u043c\u0435\u0440\u043d\u044b\u0439 \u0445\u0430\u0440\u0430\u043a\u0442\u0435\u0440<\/strong> \u0438 \u0432 \u0431\u043e\u0435\u0432\u043e\u0439 \u0441\u0440\u0435\u0434\u0435 \u0440\u0430\u0441\u0441\u0447\u0438\u0442\u044b\u0432\u0430\u044e\u0442\u0441\u044f \u0438\u043d\u0434\u0438\u0432\u0438\u0434\u0443\u0430\u043b\u044c\u043d\u043e \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f. \u0421\u043f\u0430\u0441\u0438\u0431\u043e!<\/p>\n<p>\u041f\u043e\u043b\u0435\u0437\u043d\u044b\u0435 \u0441\u0441\u044b\u043b\u043a\u0438:<\/p>\n<ul>\n<li>\n<p><a href=\"https:\/\/www.anycodings.com\/1questions\/2963447\/java-using-much-more-memory-than-heap-size-or-size-correctly-docker-memory-limit\"><u>https:\/\/www.anycodings.com\/1questions\/2963447\/java-using-much-more-memory-than-heap-size-or-size-correctly-docker-memory-limit<\/u><\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/betterprogramming.pub\/understanding-the-jvm-memory-model-heap-vs-non-heap-c14aa6fa703e\"><u>https:\/\/betterprogramming.pub\/understanding-the-jvm-memory-model-heap-vs-non-heap-c14aa6fa703e<\/u><\/a><\/p>\n<\/li>\n<\/ul>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"v-portal\" style=\"display:none;\"><\/div>\n<\/div>\n<p> <!----> <!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/company\/domclick\/blog\/691240\/\"> https:\/\/habr.com\/ru\/company\/domclick\/blog\/691240\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<p>\u0414\u0440\u0443\u0437\u044c\u044f, \u0432\u0441\u0435\u043c \u043f\u0440\u0438\u0432\u0435\u0442! \u041a\u0430\u043a \u0438\u0437\u0432\u0435\u0441\u0442\u043d\u043e, \u0432 Kubernetes \u0443 \u043a\u0430\u0436\u0434\u043e\u0433\u043e pod\u2019\u0430 \u0435\u0441\u0442\u044c \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u0435 \u043d\u0430\u00a0 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u043f\u0430\u043c\u044f\u0442\u0438 (<code>limits.memory<\/code>), \u0438, \u043a\u0430\u043a \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442 \u043e\u043f\u044b\u0442, \u0434\u0430\u043b\u0435\u043a\u043e \u043d\u0435 \u0432\u0441\u0435\u0433\u0434\u0430 \u043e\u0447\u0435\u0432\u0438\u0434\u043d\u043e, \u043a\u0430\u043a JVM-\u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0438\u043d\u0442\u0435\u0440\u043f\u0440\u0435\u0442\u0438\u0440\u0443\u0435\u0442 \u044d\u0442\u0443 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0443, \u0447\u0442\u043e \u043f\u043e\u0440\u043e\u0439 \u043c\u043e\u0436\u0435\u0442 \u043f\u0440\u0438\u0432\u043e\u0434\u0438\u0442\u044c \u043a OOMKill.<\/p>\n<p>\u042f \u0445\u043e\u0442\u0435\u043b \u0431\u044b \u043f\u043e\u0434\u0435\u043b\u0438\u0442\u044c\u0441\u044f \u043e\u0434\u043d\u0438\u043c \u0438\u0437 \u0441\u043f\u043e\u0441\u043e\u0431\u043e\u0432 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438 \u043f\u0430\u043c\u044f\u0442\u0438 \u0434\u043b\u044f Java-\u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0439 \u0432 Kubernetes. \u0421\u0440\u0430\u0437\u0443 \u0441\u043a\u0430\u0436\u0443, \u0447\u0442\u043e \u0438\u0442\u043e\u0433\u043e\u0432\u044b\u0435 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438, \u043a \u043a\u043e\u0442\u043e\u0440\u044b\u043c \u043c\u044b \u043f\u0440\u0438\u0434\u0451\u043c, \u0431\u0443\u0434\u0443\u0442 \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043d\u044b \u043b\u0438\u0448\u044c \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043f\u0440\u0438\u043c\u0435\u0440\u0430 \u0438 \u0434\u043e\u043b\u0436\u043d\u044b \u043d\u0430\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u0442\u044c\u0441\u044f \u0438\u043d\u0434\u0438\u0432\u0438\u0434\u0443\u0430\u043b\u044c\u043d\u043e \u043f\u043e\u0434 \u043a\u0430\u0436\u0434\u043e\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435. \u0420\u0430\u0441\u0441\u043c\u0430\u0442\u0440\u0438\u0432\u0430\u0442\u044c \u0431\u0443\u0434\u0435\u043c \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438 \u0438 \u043c\u0435\u0442\u0440\u0438\u043a\u0438 \u043e\u0431\u044b\u0447\u043d\u043e\u0433\u043e \u043c\u0438\u043a\u0440\u043e\u0441\u0435\u0440\u0432\u0438\u0441\u0430 \u043d\u0430 Spring boot, \u0438\u043d\u0442\u0435\u0433\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0433\u043e \u0441\u043e Spring Boot Admin (\u0434\u0430\u043b\u0435\u0435 \u043f\u0440\u043e\u0441\u0442\u043e SBA).<\/p>\n<p>\u0414\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u043e\u0441\u0432\u0435\u0436\u0438\u043c \u0442\u0435\u043e\u0440\u0438\u044e \u043f\u043e \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u0443 \u043f\u0430\u043c\u044f\u0442\u0438 \u0432 Java. \u0412\u043a\u0440\u0430\u0442\u0446\u0435, \u0433\u043b\u043e\u0431\u0430\u043b\u044c\u043d\u043e \u043f\u0430\u043c\u044f\u0442\u044c \u0434\u0435\u043b\u0438\u0442\u0441\u044f \u043d\u0430 \u0434\u0432\u0430 \u0440\u0430\u0437\u0434\u0435\u043b\u0430, <strong>\u0443\u043f\u0440\u043e\u0449\u0435\u043d\u043d\u043e<\/strong>:<\/p>\n<ul>\n<li>\n<p>Heap. \u042d\u0442\u043e\u0442 \u0440\u0430\u0437\u0434\u0435\u043b \u0434\u0435\u043b\u0438\u0442\u0441\u044f \u043d\u0430 \u043f\u043e\u0434\u0440\u0430\u0437\u0434\u0435\u043b\u044b:<\/p>\n<ul>\n<li>\n<p>Eden \u2014 \u0434\u043b\u044f \u0432\u043d\u043e\u0432\u044c \u0441\u043e\u0437\u0434\u0430\u043d\u043d\u044b\u0445 \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432, \u0447\u0438\u0441\u0442\u0438\u0442\u0441\u044f \u043f\u0440\u0438 \u043a\u0430\u0436\u0434\u043e\u0439 \u0441\u0431\u043e\u0440\u043a\u0435 \u043c\u0443\u0441\u043e\u0440\u0430 (Minor GC).<\/p>\n<\/li>\n<li>\n<p>Survivor \u2014 \u0434\u043b\u044f \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432, \u043f\u0435\u0440\u0435\u0436\u0438\u0432\u0448\u0438\u0445 Minor GC.<\/p>\n<\/li>\n<li>\n<p>Tenured \u2014 \u0434\u043b\u044f \u0434\u043e\u043b\u0433\u043e\u0436\u0438\u0432\u0443\u0449\u0438\u0445 \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432, \u0447\u0438\u0441\u0442\u0438\u0442\u0441\u044f \u043f\u0440\u0438 Major GC.<\/p>\n<\/li>\n<\/ul>\n<\/li>\n<li>\n<p>Non-heap. \u0421\u043e\u0441\u0442\u043e\u0438\u0442 \u0438\u0437:<\/p>\n<ul>\n<li>\n<p>Metaspace (\u0438 \u0432 \u0441\u043e\u0441\u0442\u0430\u0432\u0435 \u043d\u0435\u0433\u043e Compressed Class Space) \u2014 \u043c\u0435\u0442\u0430\u0434\u0430\u043d\u043d\u044b\u0435 \u0437\u0430\u0433\u0440\u0443\u0436\u0435\u043d\u043d\u044b\u0445 \u043a\u043b\u0430\u0441\u0441\u043e\u0432<\/p>\n<\/li>\n<li>\n<p>Code Cache \u2014 \u0434\u043b\u044f \u0441\u043a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0433\u043e JIT-\u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440\u043e\u043c<\/p>\n<\/li>\n<li>\n<p>ThreadStackArea<\/p>\n<\/li>\n<li>\n<p>Direct buffers<\/p>\n<\/li>\n<li>\n<p>Garbage collection<\/p>\n<\/li>\n<li>\n<p>Symbol tables \u0438 \u043f\u0440\u043e\u0447\u0438\u0435, \u043d\u0430 \u0447\u0435\u043c \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u043e \u043e\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0442\u044c\u0441\u044f \u043d\u0435 \u0431\u0443\u0434\u0435\u043c<\/p>\n<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<p>\u0418\u0442\u043e\u0433\u043e:<\/p>\n<p>Heap (Eden, Survivor, Tenured) + Non-heap (Metaspace + Code Cache + Thread stack area + Direct buffers + Symbol tables + Other JVM structures)<\/p>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c, \u043a\u0430\u043a \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 c \u043f\u0430\u043c\u044f\u0442\u044c\u044e \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u043d\u0430 Spring Boot \u0431\u0435\u0437 \u043a\u0430\u043a\u043e\u0439-\u043b\u0438\u0431\u043e \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438 \u043f\u0430\u043c\u044f\u0442\u0438, \u0437\u0430\u0434\u0430\u0432 memory.limits \u0432 \u041aubernetes \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 1280 \u041c\u0431.\u00a0<\/p>\n<p>\u0415\u0441\u043b\u0438 \u043d\u0430\u0441\u0442\u0440\u043e\u0435\u043d Native memory tracking (NMT), \u0442\u043e \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u0443\u044e \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u043a\u043e\u043c\u0430\u043d\u0434\u043e\u0439 <code>jcmd 1 VM.native_memory<\/code>.<\/p>\n<details class=\"spoiler\">\n<summary>Native Memory Tracking<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"java\">Total: reserved=2014514KB, committed=626614KB -                 Java Heap (reserved=327680KB, committed=259652KB)                             (mmap: reserved=327680KB, committed=259652KB)    -                     Class (reserved=1229865KB, committed=205737KB)                             (classes #36029)                             (  instance classes #33803, array classes #2226)                             (malloc=7209KB #105907)                              (mmap: reserved=1222656KB, committed=198528KB)                              (  Metadata:   )                             (    reserved=174080KB, committed=173568KB)                             (    used=169946KB)                             (    free=3622KB)                             (    waste=0KB =0.00%)                             (  Class space:)                             (    reserved=1048576KB, committed=24960KB)                             (    used=22922KB)                             (    free=2038KB)                             (    waste=0KB =0.00%)   -                    Thread (reserved=134801KB, committed=10461KB)                             (thread #82)                             (stack: reserved=134408KB, committed=10068KB)                             (malloc=296KB #494)                              (arena=97KB #163)   -                      Code (reserved=251808KB, committed=80620KB)                             (malloc=4120KB #15476)                              (mmap: reserved=247688KB, committed=76500KB)    -                        GC (reserved=2219KB, committed=2003KB)                             (malloc=1147KB #4677)                              (mmap: reserved=1072KB, committed=856KB)    -                  Compiler (reserved=907KB, committed=907KB)                             (malloc=777KB #1701)                              (arena=131KB #5)   -                  Internal (reserved=9479KB, committed=9479KB)                             (malloc=9479KB #19066)    -                     Other (reserved=4154KB, committed=4154KB)                             (malloc=4154KB #191)    -                    Symbol (reserved=40259KB, committed=40259KB)                             (malloc=33634KB #418136)                              (arena=6624KB #1)   -    Native Memory Tracking (reserved=9068KB, committed=9068KB)                             (malloc=32KB #432)                              (tracking overhead=9035KB)   -               Arena Chunk (reserved=2484KB, committed=2484KB)                             (malloc=2484KB)    -                   Logging (reserved=4KB, committed=4KB)                             (malloc=4KB #189)    -                 Arguments (reserved=31KB, committed=31KB)                             (malloc=31KB #498)    -                    Module (reserved=1158KB, committed=1158KB)                             (malloc=1158KB #6305)    -              Synchronizer (reserved=558KB, committed=558KB)                             (malloc=558KB #4724)    -                 Safepoint (reserved=8KB, committed=8KB)                             (mmap: reserved=8KB, committed=8KB)    -                   Unknown (reserved=32KB, committed=32KB)                             (mmap: reserved=32KB, committed=32KB) <\/code><\/pre>\n<\/p>\n<\/div>\n<\/details>\n<p>SBA:<\/p>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043d\u0430 \u0434\u0430\u043d\u043d\u044b\u0435 \u0438\u0437 \u0430\u0434\u043c\u0438\u043d\u043a\u0438:<\/p>\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<p>\u0412\u0438\u0434\u043d\u043e, \u0447\u0442\u043e \u0434\u043b\u044f Heap \u0432\u044b\u0434\u0435\u043b\u0435\u043d\u043e \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e \u0432\u0441\u0435\u0433\u043e 324 \u041c\u0431 \u0438 \u0434\u043b\u044f Non-heap 1,33 \u0413\u0431,\u043f\u0440\u0438 \u0442\u043e\u043c \u0447\u0442\u043e \u043f\u0430\u043c\u044f\u0442\u0438 \u043d\u0430 pod \u0431\u044b\u043b\u043e \u0432\u044b\u0434\u0435\u043b\u0435\u043d\u043e \u0432\u0441\u0435\u0433\u043e 1280 \u041c\u0431. \u0415\u0441\u043b\u0438 \u0441\u043b\u043e\u0436\u0438\u0442\u044c \u0440\u0430\u0437\u043c\u0435\u0440\u044b Heap \u0438 Non-heap, \u0442\u043e \u0432\u0438\u0434\u043d\u043e, \u0447\u0442\u043e \u043e\u0431\u044a\u0451\u043c \u043f\u0430\u043c\u044f\u0442\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0433\u043e\u0442\u043e\u0432\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435, \u0432\u044b\u0445\u043e\u0434\u0438\u0442 \u0434\u0430\u043b\u0435\u043a\u043e \u0437\u0430 \u043f\u0440\u0435\u0434\u0435\u043b\u044b \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u044f \u0434\u043b\u044f \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u0430. \u0427\u0442\u043e \u0436, OOMKill \u043d\u0430\u043c \u043e\u0431\u0435\u0441\u043f\u0435\u0447\u0435\u043d \ud83d\ude42<\/p>\n<p>\u041f\u043e\u043f\u0440\u043e\u0431\u0443\u0435\u043c \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u043d\u0430\u0441\u0442\u0440\u043e\u0438\u0442\u044c \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435. \u041f\u0440\u0438 \u044d\u0442\u043e\u043c \u0441\u0442\u043e\u0438\u0442 \u043f\u043e\u043c\u043d\u0438\u0442\u044c, \u0447\u0442\u043e \u0443 \u043d\u0430\u0441 \u0434\u043b\u044f \u0440\u0430\u0437\u043d\u044b\u0445 \u0441\u0442\u0435\u043d\u0434\u043e\u0432 (QA, stage, prod) \u043c\u043e\u0433\u0443\u0442 \u0442\u0440\u0435\u0431\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0435 \u043e\u0431\u044a\u0451\u043c\u044b \u043f\u0430\u043c\u044f\u0442\u0438. \u0414\u043b\u044f \u0441\u0431\u043e\u0440\u043a\u0438 \u043e\u0431\u0440\u0430\u0437\u043e\u0432 \u043c\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0443 <a href=\"https:\/\/github.com\/GoogleContainerTools\/jib\"><u>JIB<\/u><\/a>, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0443\u0434\u043e\u0431\u043d\u043e \u043d\u0430\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u0442\u044c \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u0437\u0430\u043f\u0443\u0441\u043a\u0430 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0432 entry.sh.<\/p>\n<p>\u041d\u0430\u0448\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u0442\u0441\u044f \u0432 Docker \u043f\u043e \u043a\u043e\u043c\u0430\u043d\u0434\u0435:<\/p>\n<pre><code class=\"java\">java \\ -Xms${HEAP_SIZE_MB}M \\ -Xmx${HEAP_SIZE_MB}M \\ -Xss1M \\ -XX:MaxMetaspaceSize=${METASPACE_SIZE_MB}M \\ -XX:CompressedClassSpaceSize=${COMPRESSED_CLASS_SPACE_SIZE_MB}M \\ -XX:ReservedCodeCacheSize=${RESERVED_CODE_CACHE_SIZE_MB}M \\ -XX:MaxDirectMemorySize=${DIRECT_MEMORY_SIZE_MB}M \\ -XX:NativeMemoryTracking=summary \\ -cp \"\/app\/resources:\/app\/classes:\/app\/libs\/*\" ru.example.application.DemoApplication<\/code><\/pre>\n<p>\u0422\u0443\u0442 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438 Heap \u0438 Non-heap \u0440\u0430\u0441\u043f\u0438\u0441\u0430\u043d\u044b \u043f\u043e \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438. \u041f\u043e\u043f\u0440\u043e\u0431\u0443\u0435\u043c \u0440\u0430\u0437\u043e\u0431\u0440\u0430\u0442\u044c\u0441\u044f. \u041d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438 Heap:<\/p>\n<pre><code class=\"java\">-Xms${HEAP_SIZE_MB}M \\ -Xmx${HEAP_SIZE_MB}M \\<\/code><\/pre>\n<p>\u00a0\u041d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438 Non-heap:<\/p>\n<pre><code class=\"java\">-Xss1M \\ -XX:MaxMetaspaceSize=${METASPACE_SIZE_MB}M \\ -XX:CompressedClassSpaceSize=${COMPRESSED_CLASS_SPACE_SIZE_MB}M \\ -XX:ReservedCodeCacheSize=${RESERVED_CODE_CACHE_SIZE_MB}M \\ -XX:MaxDirectMemorySize=${DIRECT_MEMORY_SIZE_MB}M \\<\/code><\/pre>\n<p>\u042d\u0442\u0438 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435 \u043c\u043e\u0436\u043d\u043e \u0432\u044b\u0441\u0447\u0438\u0442\u0430\u0442\u044c \u043f\u0440\u0438 \u0437\u0430\u043f\u0443\u0441\u043a\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0432 entry.sh, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 \u043f\u043e \u0444\u043e\u0440\u043c\u0443\u043b\u0435 (\u043f\u0440\u0438\u043c\u0435\u0440\u043d\u043e\u0439):<\/p>\n<pre><code class=\"java\">#Converting a pod memory limit from bytes to megabytes POD_MEM_LIMIT_MB=`expr $POD_MEM_LIMIT \/ 1024 \/ 1024`   #Calculating the metaspace size METASPACE_SIZE_MB=`expr $POD_MEM_LIMIT_MB \/ 5`   #Calculating the compressed class space size COMPRESSED_CLASS_SPACE_SIZE_MB=`expr $METASPACE_SIZE_MB \/ 5`   #Calculating the reserved code cache size #(not a part of the metaspace but it is easier to get it relatively) RESERVED_CODE_CACHE_SIZE_MB=`expr $METASPACE_SIZE_MB \/ 3` echo \"RESERVED_CODE_CACHE_SIZE_MB=\"$RESERVED_CODE_CACHE_SIZE_MB   #Calculating the reserved code cache size DIRECT_MEMORY_SIZE_MB=`expr $METASPACE_SIZE_MB \/ 16` echo \"DIRECT_MEMORY_SIZE_MB=\"$DIRECT_MEMORY_SIZE_MB   #Calculating the reserved system usage and other purposes OTHER_USAGE_MB=`expr $POD_MEM_LIMIT_MB \/ 4`   #Calculating total non heap size NON_HEAP_SIZE_MB=`expr $METASPACE_SIZE_MB + $RESERVED_CODE_CACHE_SIZE_MB + $DIRECT_MEMORY_SIZE_MB + $OTHER_USAGE_MB`   #Calculating the heap size HEAP_SIZE_MB=`expr $POD_MEM_LIMIT_MB - $NON_HEAP_SIZE_MB`<\/code><\/pre>\n<p>\u0420\u0430\u0437\u043c\u0435\u0440 Metaspace, \u043a\u0430\u043a \u0438 \u0434\u0440\u0443\u0433\u0438\u0445 \u0441\u0435\u0433\u043c\u0435\u043d\u0442\u043e\u0432, \u043c\u043e\u0436\u043d\u043e \u0443\u043a\u0430\u0437\u0430\u0442\u044c \u0438 \u0444\u0438\u043a\u0441\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u043c, \u043d\u043e \u0434\u043b\u044f \u043f\u0440\u0438\u043c\u0435\u0440\u0430 \u043e\u0441\u0442\u0430\u0432\u0438\u043c \u0432\u044b\u0447\u0438\u0441\u043b\u044f\u0435\u043c\u044b\u043c.<\/p>\n<p>\u0418 \u043f\u043e\u0441\u043b\u0435 \u0442\u0430\u043a\u043e\u0439 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438 \u0441\u043d\u043e\u0432\u0430 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u043c<code>jcmd 1 VM.native_memory<\/code> \u0438 \u043a\u0430\u0440\u0442\u0438\u043d\u0430 \u0432\u0438\u0434\u0438\u0442\u0441\u044f \u0443\u0436\u0435 \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u0438\u043d\u043e\u0439:<\/p>\n<details class=\"spoiler\">\n<summary>\u041f\u043e\u0434\u0440\u043e\u0431\u043d\u0435\u0435<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"java\">Total: reserved=1109330KB, committed=961126KB -                 Java Heap (reserved=618496KB, committed=618496KB)                             (mmap: reserved=618496KB, committed=618496KB)    -                     Class (reserved=230915KB, committed=202995KB)                             (classes #35923)                             (  instance classes #33695, array classes #2228)                             (malloc=6659KB #96909)                              (mmap: reserved=224256KB, committed=196336KB)                              (  Metadata:   )                             (    reserved=172032KB, committed=171512KB)                             (    used=167998KB)                             (    free=3514KB)                             (    waste=0KB =0.00%)                             (  Class space:)                             (    reserved=52224KB, committed=24824KB)                             (    used=22857KB)                             (    free=1967KB)                             (    waste=0KB =0.00%)   -                    Thread (reserved=98449KB, committed=10349KB)                             (thread #82)                             (stack: reserved=98056KB, committed=9956KB)                             (malloc=296KB #494)                              (arena=97KB #163)   -                      Code (reserved=91279KB, committed=59095KB)                             (malloc=3559KB #14025)                              (mmap: reserved=87720KB, committed=55536KB)    -                        GC (reserved=3134KB, committed=3134KB)                             (malloc=1114KB #4516)                              (mmap: reserved=2020KB, committed=2020KB)    -                  Compiler (reserved=665KB, committed=665KB)                             (malloc=534KB #1752)                              (arena=131KB #5)   -                  Internal (reserved=8429KB, committed=8429KB)                             (malloc=8429KB #16669)    -                     Other (reserved=4792KB, committed=4792KB)                             (malloc=4792KB #149)    -                    Symbol (reserved=40213KB, committed=40213KB)                             (malloc=33588KB #415272)<\/code><\/pre>\n<\/div>\n<\/details>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-339272","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/339272","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=339272"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/339272\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=339272"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=339272"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=339272"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}