Skip to content
This repository has been archived by the owner on Jul 31, 2023. It is now read-only.

A memory leak cause by the active set of spanStore #1245

Closed
NanoRed opened this issue Dec 14, 2020 · 1 comment
Closed

A memory leak cause by the active set of spanStore #1245

NanoRed opened this issue Dec 14, 2020 · 1 comment
Labels

Comments

@NanoRed
Copy link
Contributor

NanoRed commented Dec 14, 2020

Please answer these questions before submitting a bug report.

What version of OpenCensus are you using?

v0.22.5

What version of Go are you using?

1.13.15

What did you do?

import (
	"go.opencensus.io/trace"
	_ "go.opencensus.io/zpages" // internal.LocalSpanStoreEnabled = true
)

type SpanTest struct {
	Ctx   context.Context
	Count int
}

func (s *SpanTest) Inc() {
	span := trace.StartSpan(s.Ctx, "test")
	defer span.End()
}

func main() {
	test := &SpanTest{
		Ctx: context.Background(),
	}
	go func() {
		for {
			test.Inc()
		}
	}()
	for {}
}

it make memory usage gradually increasing.
and i have found the problem:
opencensus-go/trace/trace.go line:269 ss.add(NewSpan(s))
opencensus-go/trace/trace.go line:294 s.spanStore.finished(NewSpan(s), sd)
when add a new span to the spanStore active set. it wrote a wrong way to release the active set, it shouldn't use NewSpan() to wrap the *span and pass to the finished function

@NanoRed
Copy link
Contributor Author

NanoRed commented Dec 18, 2020

has been fixed

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

1 participant