public static void main(String[] args) {
        
        System.out.println("程序启动-->可用内存:"+(getSystemMem()/1024/1024)+"M");
        Long systemMem = getSystemMem();
        Map<byte[],Byte> map = new HashMap<byte[], Byte>();
        for(int i=0;i<100000000;i++){
            map.put(StringUtils.md5("http://www.baidu.com"+i),Byte.parseByte("1"));
            if(i%100000==99999){
                System.out.println("存储"+(i+1)+"后,使用内存:"+((systemMem-getSystemMem())/1024/1024)+"M");
            }
        }
    }
    
    public static Long getSystemMem(){
         OperatingSystemMXBean osmb = (OperatingSystemMXBean) ManagementFactory.getOperatingSystemMXBean();   
         return osmb.getFreePhysicalMemorySize();
    }

 

相关文章:

  • 2022-03-03
  • 2021-10-21
  • 2022-12-23
  • 2021-11-29
  • 2021-11-29
  • 2021-08-05
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-07-24
  • 2021-05-07
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案