java,

Learn with JVM Memory

Cui Cui Follow Jan 06, 2022 · 3 mins read
Learn with JVM Memory
Share this

“Whatever”. -referenced from here

Application Layer protocols

Memory


❯ kubectl exec kubernetes_pod_id -- sh

    / # jcmd 1 GC.heap_dump /tmp/dump.hprof
    / # jcmd 1 VM.native_memory
    1:

    Native Memory Tracking:

    Total: reserved=721758KB, committed=411778KB
    -                 Java Heap (reserved=262144KB, committed=125952KB)
                                (mmap: reserved=262144KB, committed=125952KB)

    -                     Class (reserved=159282KB, committed=110462KB)
                                (classes #18452)
                                (  instance classes #17247, array classes #1205)
                                (malloc=3634KB #60750)
                                (mmap: reserved=155648KB, committed=106828KB)
                                (  Metadata:   )
                                (    reserved=94208KB, committed=93644KB)
                                (    used=92123KB)
                                (    free=1521KB)
                                (    waste=0KB =0.00%)
                                (  Class space:)
                                (    reserved=61440KB, committed=13184KB)
                                (    used=12041KB)
                                (    free=1143KB)
                                (    waste=0KB =0.00%)

    -                    Thread (reserved=60851KB, committed=6203KB)
                                (thread #59)
                                (stack: reserved=60572KB, committed=5924KB)
                                (malloc=212KB #356)
                                (arena=67KB #116)

    -                      Code (reserved=128593KB, committed=63321KB)
                                (malloc=4753KB #20362)
                                (mmap: reserved=123840KB, committed=58568KB)

    -                        GC (reserved=47470KB, committed=42422KB)
                                (malloc=4938KB #31628)
                                (mmap: reserved=42532KB, committed=37484KB)

    -                  Compiler (reserved=645KB, committed=645KB)
                                (malloc=513KB #1618)
                                (arena=133KB #5)

    -                  Internal (reserved=1280KB, committed=1280KB)
                                (malloc=1248KB #1859)
                                (mmap: reserved=32KB, committed=32KB)

    -                     Other (reserved=33045KB, committed=33045KB)
                                (malloc=33045KB #52)

    -                    Symbol (reserved=21247KB, committed=21247KB)
                                (malloc=18458KB #240447)
                                (arena=2789KB #1)

    -    Native Memory Tracking (reserved=5700KB, committed=5700KB)
                                (malloc=18KB #224)
                                (tracking overhead=5683KB)

    -               Arena Chunk (reserved=755KB, committed=755KB)
                                (malloc=755KB)

    -                   Logging (reserved=4KB, committed=4KB)
                                (malloc=4KB #192)

    -                 Arguments (reserved=18KB, committed=18KB)
                                (malloc=18KB #493)

    -                    Module (reserved=438KB, committed=438KB)
                                (malloc=438KB #3121)

    -              Synchronizer (reserved=277KB, committed=277KB)
                                (malloc=277KB #2341)

    -                 Safepoint (reserved=8KB, committed=8KB)
                                (mmap: reserved=8KB, committed=8KB)


❯ kubectl top pod pod_id
NAME                                 CPU(cores)   MEMORY(bytes)
kubernetes-pods-654fd7b5dd-f9rm6     11m          335Mi

❯ kubectl exec pod_id -- sh

# jcmd 1 VM.native_memory
Total: reserved=623491KB, committed=325515KB

# cd /sys/fs/cgroup/memory
# ls
    cgroup.clone_children       memory.force_empty          memory.kmem.slabinfo        memory.kmem.tcp.usage_in_bytes  memory.move_charge_at_immigrate  memory.soft_limit_in_bytes  memory.use_hierarchy
    cgroup.event_control   memory.kmem.failcnt         memory.kmem.tcp.failcnt         memory.kmem.usage_in_bytes      memory.numa_stat         memory.stat         notify_on_release
    cgroup.procs           memory.kmem.limit_in_bytes      memory.kmem.tcp.limit_in_bytes      memory.limit_in_bytes       memory.oom_control           memory.swappiness       tasks
    memory.failcnt         memory.kmem.max_usage_in_bytes  memory.kmem.tcp.max_usage_in_bytes  memory.max_usage_in_bytes       memory.pressure_level        memory.usage_in_bytes

# cat memory.limit_in_bytes
536870912

# cat  memory.usage_in_bytes
372219904

Copy remote container host file to local

    kubectl cp aks-ssh2-6cd4948f6f-fp9tl:/home/azureuser/test.cap ./test.cap

Check JVM GC

# java -XX:+PrintCommandLineFlags -version
    -XX:InitialHeapSize=8388608 -XX:MaxHeapSize=134217728 -XX:+PrintCommandLineFlags -XX:ReservedCodeCacheSize=251658240 -XX:+SegmentedCodeCache -XX:+UseCompressedClassPointers -XX:+UseCompressedOops -XX:+UseSerialGC
    openjdk version "11.0.15" 2022-04-19
    OpenJDK Runtime Environment 18.9 (build 11.0.15+10)
    OpenJDK 64-Bit Server VM 18.9 (build 11.0.15+10, mixed mode, sharing)
Join Newsletter
Get the latest news right in your inbox. We never spam!
Cui
Written by Cui Follow
Hi, I am Z, the coder for cuizhanming.com!