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

Shouldn't ArenaPool call arena.Reset() on Put or on Get? #61

Open
KromDaniel opened this issue Feb 8, 2021 · 2 comments
Open

Shouldn't ArenaPool call arena.Reset() on Put or on Get? #61

KromDaniel opened this issue Feb 8, 2021 · 2 comments

Comments

@KromDaniel
Copy link

Hey,
Not sure this is a bug or by design, I didn't find anything on the docs mention that and I think it made my app OOM

This is the implementation of arena pool:

// Get returns an Arena from ap.
//
// The Arena must be Put to ap after use.
func (ap *ArenaPool) Get() *Arena {
	v := ap.pool.Get()
	if v == nil {
		return &Arena{}
	}
	return v.(*Arena)
}

// Put returns a to ap.
//
// a and objects created by a cannot be used after a is put into ap.
func (ap *ArenaPool) Put(a *Arena) {
	ap.pool.Put(a)
}

However (AFAIK), pools usually should call reset on returned object
so shouldn't Put implementation should be:

a.Reset()
ap.pool.Put(a)

I can call .Reset myself but since the pool is not doing that, I'm afraid that I might be missing something?

Would really appreciate if you have time to look,
Thanks!

@develar
Copy link

develar commented Aug 17, 2021

Same question.

@saartamir
Copy link

Same here... I see that the 'b' field is keep growing if I'm not using Reset()

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

No branches or pull requests

3 participants