Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

strconv: unit test failure #3495

Closed
alberts opened this issue Apr 7, 2012 · 3 comments
Closed

strconv: unit test failure #3495

alberts opened this issue Apr 7, 2012 · 3 comments

Comments

@alberts
Copy link
Contributor

alberts commented Apr 7, 2012

What steps will reproduce the problem?
If possible, include a link to a program on play.golang.org.

run strconv unit tests a few hundred times

What do you see instead?

--- FAIL: TestAppendUintDoesntAllocate-62 (0.00 seconds)
itoa_test.go:148: with local buffer, did 2 allocations, want 1

Which compiler are you using (5g, 6g, 8g, gccgo)?

6g

Which operating system are you using?

linux

Which version are you using?  (run 'go version')

go version weekly.2012-03-27 +d9e4f47ae341

Please provide any additional information below.

GOMAXPROCS=62 if that matters.
@bradfitz
Copy link
Contributor

Comment 1:

I think last time this came up, we assumed it was a GC that ran during the test being
measured, but we've already forced a GC here before measurement:
In itoa_test.go:
func numAllocations(f func()) int {
        runtime.GC()
        memstats := new(runtime.MemStats)
        runtime.ReadMemStats(memstats)
        n0 := memstats.Mallocs
        f()
        runtime.ReadMemStats(memstats)
        return int(memstats.Mallocs - n0)
}

@rsc
Copy link
Contributor

rsc commented Apr 10, 2012

Comment 2:

This is a bad way to count allocations either way.
Maybe it is memory profiling, which does its own
allocations.  Package fmt's TestCountMallocs is
the right way to do it.

@davecheney
Copy link
Contributor

Comment 3:

This issue was closed by revision 84ef97b.

Status changed to Fixed.

@golang golang locked and limited conversation to collaborators Jun 24, 2016
This issue was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

5 participants