The best way to figure out where they are coming
from is to look at the 'gv' or 'web' view, which will
show the call stack (as graph arrows) leading to
malg.
Russ
> Thanks - I did that, and it seemed like nearly all the malg calls
> traced up to crosscall_amd64(). Is there a way to see it beyond that?
> (Like, am I missing something obvious?)
That will be the start of the goroutine for a program that uses cgo. It
is likely that there is nothing beyond that. The only case in which
there would be would be if you have Go code which calls C which calls
back into Go code.
Ian
So here's a little example. This program just fetches 42 web pages in
parallel using 42 goroutines.
http://dl.dropbox.com/u/19269207/myhttp.go
http://dl.dropbox.com/u/19269207/cpu.svg
http://dl.dropbox.com/u/19269207/mem.svg
http://dl.dropbox.com/u/19269207/mem_inuse_objects.svg
If you look at the mem_inuse_objects version, I have 187,245 objects
associated with malg.
So assuming that the net package uses cgo and creates goroutines,
would these goroutines show up in the count returned by
runtime.Goroutines()?
The profile at http://dl.dropbox.com/u/19269207/cpu.svg looks
more like 10% in Syscall, which seems fine. You are doing
a lot of system calls.
> The second issue I see is in the memory profile. The program has a
> huge number of allocations from runtime.malg, which I believe is used
> when creating a goroutine. My program code itself creates less than
> 200 goroutines that live for the life of the program. However, there
> are over 25,000 allocations from malg. I read another post where Rob
> indicated that a program with so many malg allocations could be
> "leaking" goroutines, but at program exit or at any given time it has
> less than 200.
Thanks for pointing this out.
This is a bug in the memory profiler, which I will fix.
It overcounts malg allocations by about 5000x.
Russ
--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.