grim/youtrack-import
Clone
Summary
Browse
Changes
Graph
Mention that a previously edited comment was discarded and don't display the old value. YI-37
draft
2020-08-03, Gary Kramlich
c827e434f2aa
Mention that a previously edited comment was discarded and don't display the old value. YI-37
package
mem
import
(
"fmt"
"runtime"
)
func
PrintMemUsage
()
{
fmt
.
Printf
(
"%s\n"
,
MemUsage
())
}
func
MemUsage
()
string
{
var
m
runtime
.
MemStats
runtime
.
ReadMemStats
(
&
m
)
var
s
string
// For info on each, see: https://golang.org/pkg/runtime/#MemStats
s
+=
fmt
.
Sprintf
(
"Alloc = %v MiB"
,
bToMb
(
m
.
Alloc
))
s
+=
fmt
.
Sprintf
(
"\tTotalAlloc = %v MiB"
,
bToMb
(
m
.
TotalAlloc
))
s
+=
fmt
.
Sprintf
(
"\tSys = %v MiB"
,
bToMb
(
m
.
Sys
))
s
+=
fmt
.
Sprintf
(
"\tNumGC = %v\n"
,
m
.
NumGC
)
return
s
}
func
bToMb
(
b
uint64
)
uint64
{
return
b
/
1024
/
1024
}