Go 运行时有很多与堆和堆栈相关的不同变量,并且一些堆栈编号是堆编号的一部分,导致混淆(对我而言)。例如,在此链接中。它说
// Stack numbers are part of the heap numbers, separate those out for user consumption
stats.StackSys = stats.StackInuse
stats.HeapInuse -= stats.StackInuse
stats.HeapSys -= stats.StackInuse
在运行时文档中(摘录如下),它给出了 7 个不同的与堆相关的字段(即 memstat 结构的字段),但没有明确说明哪些包含堆栈,类似地,堆中包含哪些堆栈字段,以及它们与总拨款。
这是一个问题,因为我想将堆与堆栈进行比较,但我不想选择包含堆栈的堆变量(显然)。
问题 1). 总分配字段是否包括堆、堆栈或两者?2) 哪些堆字段不包括数字栈?3) 哪些堆字段包含栈的数字?4) 哪些堆栈字段不包含堆的数字?
Alloc uint64 // bytes allocated and still in use
TotalAlloc uint64 // bytes allocated (even if freed)
Sys uint64 // bytes obtained from system (sum of XxxSys below)
Lookups uint64 // number of pointer lookups
Mallocs uint64 // number of mallocs
Frees uint64 // number of frees
// Main allocation heap statistics.
HeapAlloc uint64 // bytes allocated and still in use
HeapSys uint64 // bytes obtained from system
HeapIdle uint64 // bytes in idle spans
HeapInuse uint64 // bytes in non-idle span
HeapReleased uint64 // bytes released to the OS
HeapObjects uint64 // total number of allocated objects
// Low-level fixed-size structure allocator statistics.
// Inuse is bytes used now.
// Sys is bytes obtained from system.
StackInuse uint64 // bytes used by stack allocator
StackSys uint64
红糖糍粑
交互式爱情
相关分类