#Is there a way to see precise CPU, and memory usage of a Go program?

16 messages · Page 1 of 1 (latest)

ionic zinc
#

the title, I've got a compiled go binary and I'm trying to see exactly how much memory it uses (in megabytes) and its CPU usage. I'm using fedora linux. any help appreciated greatly, thanks in advance.

idle raptor
#

do you know use to use top or htop ?

ionic zinc
#

yea I've used htop, but I couldn't see it in the process list

idle raptor
#

try lunching htop as root

ionic zinc
#

should I also launch the binary as root or just my usual user?

idle raptor
#

your usual user

#

htop should work if you lunch it as the same user but I'm lazy and lunching it as root should always work

ionic zinc
#

alright, ill try this very soon and report back the results, thank you.

ionic zinc
#

@idle raptor Thank you! with your help i managed to find my program's memory usage

for those who may need this in the future:

i ran sudo htop, used the search feature in htop to find my program, and then i looked at the RES column, and that states memory usage in kb, which if you put into a quick converter for megabytes or gigabytes tells you exactly how much a paticular program on your system is using.

dreamy lotus
gritty zenithBOT
#

    func ReadMemStats(m *MemStats)

ReadMemStats populates m with memory allocator statistics.

The returned memory allocator statistics are up to date as of the call to ReadMemStats. This is in contrast with a heap profile, which is a snapshot as of the most recently completed garbage collection cycle.

ionic zinc
magic junco
gritty zenithBOT
#

Types: 2
Functions: 12

Package pprof writes runtime profiling data in the format expected by the pprof visualization tool....

More documentation omitted

magic junco
gritty zenithBOT
#

Types: 0
Functions: 6

Package pprof serves via its HTTP server runtime profiling data in the format expected by the pprof visualization tool....

More documentation omitted