コード例 #1
0
ファイル: runtime_jemalloc.go プロジェクト: csdigi/cockroach
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
ファイル: runtime_jemalloc.go プロジェクト: mjibson/cockroach
func logJemallocStats() {
	if log.V(3) {
		C.malloc_stats_print(nil, nil, nil)
	}
}
コード例 #3
0
ファイル: main_jemalloc.go プロジェクト: GitGoldie/cockroach
func init() {
	C.malloc_stats_print(nil, nil, nil)
}