首页 技术 正文
技术 2022年11月11日
0 收藏 732 点赞 2,407 浏览 1795 个字

JVM学习02:GC垃圾回收和内存分配

写在前面:本系列分享主要参考资料是  周志明老师的《深入理解Java虚拟机》第二版。

GC垃圾回收和内存分配知识要点Xmind梳理

JVM学习02:GC垃圾回收和内存分配

案例分析1-(GC日志分析示例)

package com.hs.jvm;import java.sql.Time;
import java.sql.Timestamp;
import java.text.SimpleDateFormat;public class Test { public Object instance = null;
private static final int _1MB = 1024 * 1024; //该成员属性存在的唯一目的就是占内存;
private byte[] bigSize = new byte[2* _1MB]; public static void main(String[] args){ Test objA = new Test();
Test objB = new Test(); objA.instance = objB;
objB.instance = objA; objA = null;
objB = null; System.gc(); }/*
[GC (System.gc()) [PSYoungGen: 9350K->4923K(76288K)] 9350K->4931K(251392K), 0.0047877 secs] [Times: user=0.00 sys=0.00, real=0.01 secs]
[Full GC (System.gc()) [PSYoungGen: 4923K->0K(76288K)] [ParOldGen: 8K->4808K(175104K)] 4931K->4808K(251392K), [Metaspace: 3281K->3281K(1056768K)], 0.0113745 secs] [Times: user=0.02 sys=0.00, real=0.01 secs] Heap
PSYoungGen total 76288K, used 655K [0x000000076ad80000, 0x0000000770280000, 0x00000007c0000000)
eden space 65536K, 1% used [0x000000076ad80000,0x000000076ae23ee8,0x000000076ed80000)
from space 10752K, 0% used [0x000000076ed80000,0x000000076ed80000,0x000000076f800000)
to space 10752K, 0% used [0x000000076f800000,0x000000076f800000,0x0000000770280000)
ParOldGen total 175104K, used 4808K [0x00000006c0800000, 0x00000006cb300000, 0x000000076ad80000)
object space 175104K, 2% used [0x00000006c0800000,0x00000006c0cb23c0,0x00000006cb300000)
Metaspace used 3288K, capacity 4496K, committed 4864K, reserved 1056768K
class space used 359K, capacity 388K, committed 512K, reserved 1048576K
*/ /**
* GC :表示日志开始,如果是Full GC,表示发生了"stop the world"
* System.gc(): 表示是通过System.gc()方法触发GC
* PSYoungGen : 表示GC发生的区域,且区域名称和使用的GC收集器有关,比如PSYoungGen表示新生代(使用Parallel Scavenge收集器),DefNew表示新生代(使用Serial收集器)
* 9350K->4923K(76288K):GC前该内存区域使用容量->GC后该内存区域已使用容量(该内存区域总容量)
* 0.0047877 secs:表示该内存区域GC所占用的时间(单位秒)
* [Times: user=0.00 sys=0.00, real=0.01 secs]:user、sys、real代表用户态小号的CPU时间、内核态消耗的CPU时间和操作从开始到结束所经过的墙钟时间
* */}
相关推荐
python开发_常用的python模块及安装方法
adodb:我们领导推荐的数据库连接组件bsddb3:BerkeleyDB的连接组件Cheetah-1.0:我比较喜欢这个版本的cheeta…
日期:2022-11-24 点赞:878 阅读:8,994
Educational Codeforces Round 11 C. Hard Process 二分
C. Hard Process题目连接:http://www.codeforces.com/contest/660/problem/CDes…
日期:2022-11-24 点赞:807 阅读:5,507
下载Ubuntn 17.04 内核源代码
zengkefu@server1:/usr/src$ uname -aLinux server1 4.10.0-19-generic #21…
日期:2022-11-24 点赞:569 阅读:6,350
可用Active Desktop Calendar V7.86 注册码序列号
可用Active Desktop Calendar V7.86 注册码序列号Name: www.greendown.cn Code: &nb…
日期:2022-11-24 点赞:733 阅读:6,135
Android调用系统相机、自定义相机、处理大图片
Android调用系统相机和自定义相机实例本博文主要是介绍了android上使用相机进行拍照并显示的两种方式,并且由于涉及到要把拍到的照片显…
日期:2022-11-24 点赞:512 阅读:7,768
Struts的使用
一、Struts2的获取  Struts的官方网站为:http://struts.apache.org/  下载完Struts2的jar包,…
日期:2022-11-24 点赞:671 阅读:4,845