示例#1
0
func getJemallocStats() (uint64, uint64, error) {
	var js C.JemallocStats
	// TODO(marc): should we panic here? Failure on fetching the stats may be a problem.
	if errCode := C.jemalloc_get_stats(&js); errCode != 0 {
		return 0, 0, fmt.Errorf("error code %d", errCode)
	}

	if log.V(2) {
		// Summary of jemalloc stats:
		log.Infof("jemalloc stats: allocated: %s, active: %s, metadata: %s, resident: %s, mapped: %s",
			humanize.IBytes(uint64(js.allocated)), humanize.IBytes(uint64(js.active)),
			humanize.IBytes(uint64(js.metadata)), humanize.IBytes(uint64(js.resident)),
			humanize.IBytes(uint64(js.mapped)))
	}

	if log.V(3) {
		// Detailed jemalloc stats (very verbose, includes per-arena stats).
		C.malloc_stats_print(nil, nil, nil)
	}

	return uint64(js.allocated), uint64(js.resident), nil
}
示例#2
0
func logJemallocStats() {
	if log.V(3) {
		C.malloc_stats_print(nil, nil, nil)
	}
}
示例#3
0
func init() {
	C.malloc_stats_print(nil, nil, nil)
}