Skip to content

encoding/hex: DecodeString wastes memory #29802

Closed
@rillig

Description

@rillig

What version of Go are you using?

go version go1.11.4 windows/amd64

What did you do?

https://play.golang.org/p/pbZJx5AZHpJ

What did you expect to see?

The byte slice returned by hex.DecodeString has len == cap.

What did you see instead?

The byte slice returned by hex.DecodeString is twice as large as strictly necessary.

See this rillig/pkglint commit for the real-life example where I discovered this. In a commit message shortly before that, I discovered strange sequences of hex digits in the heap dump.

Metadata

Metadata

Assignees

No one assigned

    Labels

    NeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.Performance

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions