java 查看类大小

   // 结果数据
            long gcing = Runtime.getRuntime().freeMemory();
            orderList = pageOrder.getRecords();
            long gced = Runtime.getRuntime().freeMemory();
            // 64位打印24,32位打印16 (注:是因为JVM底层内存都是以8 byte对齐的,即8的倍数)
            System.out.println("Memory used:"+(gcing -gced ));
            long size= ObjectSizeCalculator.getObjectSize(orderList);
            System.out.println("Memory used:"+size);

 

posted @ 2022-03-01 13:43  八英里  阅读(110)  评论(0编辑  收藏  举报