flink get_json_object OOM 定位

2022-05-20  本文已影响0人  loukey_j

环境版本

问题现象

 heap                                    7839M        7912M        7912M         99.08%       gc.g1_young_generation.count                  3103                                          
 g1_eden_space                           266M         338M         -1            78.70%       gc.g1_young_generation.time(ms)               149029                                        
 g1_survivor_space                       2M           2M           -1            100.00%      gc.g1_old_generation.count                    84                                            
 g1_old_gen                              7571M        7572M        7912M         95.70%       gc.g1_old_generation.time(ms)                 1728307                                       
 nonheap                                 201M         213M         1520M         13.29%                                                                                                   
 code_cache                              75M          77M          240M          31.47%                                                                                                   
 metaspace                               113M         120M         256M          44.24%                                                                                                   
 compressed_class_space                  13M          14M          1024M         1.29%                                                                                                    
 direct                                  1030M        1030M        -             100.00%                                                                                                  
 mapped                                  0K           0K           -             0.00%  

g1_old_gen 7571M 7572M 7912M 95.70% 老年代被占满

 num     #instances         #bytes  class name
----------------------------------------------
   1:      29038550     4765922152  [C
   2:      78950689     3158027560  java.util.LinkedHashMap$Entry
   3:      29037950      696910800  java.lang.String
   4:       3039863      660059128  [Ljava.util.HashMap$Node;
   5:       3037192      170082752  java.util.LinkedHashMap
   6:          7459       48344936  [B
   7:            98        3212832  [Lakka.dispatch.forkjoin.ForkJoinTask;
   8:         32815        2100160  java.nio.DirectByteBuffer
   9:         18195        2023848  java.lang.Class
  10:         33261        1862616  org.apache.flink.core.memory.MemorySegment
  11:         48302        1545664  java.util.concurrent.ConcurrentHashMap$Node
  12:         14347        1328040  [Ljava.lang.Object;
  13:         32817        1312680  sun.misc.Cleaner
  14:         32810        1049920  java.nio.DirectByteBuffer$Deallocator

问题定位

import lombok.SneakyThrows;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.UUID;

public class TEST {

    static class HashCache<K, V> extends LinkedHashMap<K, V> {

        private static final int CACHE_SIZE = 16;
        private static final int INIT_SIZE = 32;
        private static final float LOAD_FACTOR = 0.6f;

        HashCache() {
            super(INIT_SIZE, LOAD_FACTOR);
        }

        private static final long serialVersionUID = 1;

        @Override
        protected boolean removeEldestEntry(Map.Entry<K, V> eldest) {
            return size() > CACHE_SIZE;
        }
    }

    public static void main(String[] args) throws InterruptedException {
        final  HashCache<Object, Object> objectObjectHashCache = new HashCache<>();
        for(int i =0; i < 20 ; i ++){
            new Thread(new Runnable() {
                @SneakyThrows
                @Override
                public void run() {
                    while (true){
                            objectObjectHashCache.put(UUID.randomUUID(),"");
                        Thread.sleep(1);
                    }
                }
            }).start();
        }

        while (true){
            System.out.println(objectObjectHashCache.size());
            Thread.sleep(3);
        }
    }
}

上一篇 下一篇

猜你喜欢

热点阅读