xbgfy
  • idea vm参数设置

  

  • 栈溢出(其实就是递归调用没结束)
       public  static  void  stackOverFlow(){
    
                 stackOverFlow();
    
        }
    

 

  • 堆溢出
       static class TestBean{}
        /**
         *
         * 堆溢出 Java heap space
         */
        public  static  void  outOfMemory(){
            try {
                while (true){
                    list.add( new TestBean());
    
                }
            }catch (Exception e){
                System.out.println(e);
            }
    
        }

  • 运行是常量异常
      static  List  arrayList=new ArrayList();
        public  static  void    outOfMemoryPremGen(){
    
            int i=0;
            while (true){
                list.add(String.valueOf(i++).intern());
            }
        }

  • Unsafe 分配堆外内存(java nio就是这样实现)
    //Unsafe 分配内存
        private static final Unsafe unsafe = Unsafe.getUnsafe();
        private  final  static  int size=1024*1024;
        public  static   void getSyseMmory(){
            while (true){
                unsafe.allocateMemory(size);
            }
    
        }

 

分类:

技术点:

相关文章:

  • 2021-09-25
  • 2022-02-23
  • 2021-12-02
  • 2021-08-19
猜你喜欢
  • 2022-01-06
  • 2021-05-19
  • 2022-01-16
  • 2022-12-23
  • 2022-02-07
  • 2021-12-22
  • 2021-11-24
相关资源
相似解决方案