Skip to content

runtime/pprof: memory profile attributes allocation to import line #23049

@sjlee

Description

@sjlee

Please answer these questions before submitting your issue. Thanks!

What version of Go are you using (go version)?

go version go1.9.2 darwin/amd64

Does this issue reproduce with the latest release?

Yes.

What operating system and processor architecture are you using (go env)?

GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"

The profile itself was captured on a Linux docker container, and was viewed on MacOS (both on 1.9.2).

What did you do?

I opened a memory profile in the --alloc_objects mode. I listed a function to view its allocation, and it associated the allocation that was meant for bytes.NewBuffer with an import line in the source that imported the bytes package. Output from list:

(pprof) list encodeNameValuePairs
Total: 534804146
ROUTINE ======================== ...protocol.(*Msg).encodeNameValuePairs in .../message.go
  24057960   27540717 (flat, cum)  5.15% of Total
         .          .      1:package protocol
         .          .      2:
         .          .      3:import (
  12092676   12092676      4:	"bytes"
         .          .      5:	"fmt"

(lines that do not belong to the function omitted)

         .          .    148:func (m *Msg) encodeNameValuePairs(val map[string]string) []byte {
  11965284   11965284    149:	buf := bytes.NewBuffer(make([]byte, 0, defaultNVPairSize))
         .          .    150:	for k, v := range val {
         .          .    151:		if buf.Len() > 0 {
         .      36437    152:			buf.WriteByte('&')
         .          .    153:		}
         .     412648    154:		writeEscaped(k, buf)
         .      37803    155:		buf.WriteByte('=')
         .    2995869    156:		writeEscaped(v, buf)
         .          .    157:	}
         .          .    158:	return buf.Bytes()
         .          .    159:}
         .          .    160:

I confirmed that the first allocation number (12092676) is indeed caused by bytes.NewBuffer by writing a small program to match the allocation numbers from this function.

What did you expect to see?

The first allocation number (12092676) to be correctly attributed to the actual line.

What did you see instead?

It was attributed to the import line.

Metadata

Metadata

Assignees

No one assigned

    Labels

    FrozenDueToAgeNeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.WaitingForInfoIssue is not actionable because of missing required information, which needs to be provided.

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions