golang之内存使用报告

golang之内存使用报告

golang 的 runtime包可以用来检测内存的使用情况,主要内存使用情况,都在MemStats结构体里面

 type MemStats struct {
    // 常用数据   
    Alloc      uint64 // 系统分配了,并且仍在使用的内存
    TotalAlloc uint64 // 分配的内存总量
    Sys        uint64 // 从系统得到的内存总量
    Lookups    uint64 // 回环指针数量
    Mallocs    uint64 // 分配次数
    Frees      uint64 // 内存释放次数

    // 主要的堆数据
    HeapAlloc    uint64 // 分配了之后,并且仍在使用的堆内存
    HeapSys      uint64 // 从系统申请的堆内存大小
    HeapIdle     uint64 // 闲置状态的的span
    HeapInuse    uint64 // 非限制状体的span  HeapIdle + HeapInuse = HeapSys
    HeapReleased uint64 // 从系统中释放的内存大小
    HeapObjects  uint64 // 一共分配的对象数量

    //底层的固定分配数据
    //	按字节计算容量
    //	Sys is bytes obtained from system.
    StackInuse  uint64 // 栈分配使用的内存
    StackSys    uint64  //系统帐使用的内存量
    MSpanInuse  uint64 // mspan结构 使用的量
    MSpanSys    uint64
    MCacheInuse uint64 // mcache 结构使用的量
    MCacheSys   uint64  //系统mcache结构使用的量
    BuckHashSys uint64 // profiling bucket hash table,系统hash表使用情况
    GCSys       uint64 // GC 的元数据
    OtherSys    uint64 // 其他的系统分配数据

    // Garbage collector statistics.
    NextGC       uint64 // 当 HeapAlloc 大于该值的时候,会进行垃圾回收
    LastGC       uint64 // 上一次垃圾回收的时间
    PauseTotalNs uint64
    PauseNs      [256]uint64 // circular buffer of recent GC pause durations, most recent at [(NumGC+255)%256]
    PauseEnd     [256]uint64 // circular buffer of recent GC pause end times
    NumGC        uint32
    EnableGC     bool
    DebugGC      bool

    // Per-size allocation statistics.
    // 61 is NumSizeClasses in the C code.
    BySize [61]struct {
        Size    uint32
        Mallocs uint64
        Frees   uint64
    }
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值