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

Possible memory leak because of Ticker #19

Merged
merged 1 commit into from
Dec 1, 2018

Conversation

zplzpl
Copy link

@zplzpl zplzpl commented Nov 19, 2018

// NewTicker returns a new Ticker containing a channel that will send the
// time with a period specified by the duration argument.
// It adjusts the intervals or drops ticks to make up for slow receivers.
// The duration d must be greater than zero; if not, NewTicker will panic.
// Stop the ticker to release associated resources.
func NewTicker(d Duration) *Ticker {
……
}

@codecov
Copy link

codecov bot commented Nov 19, 2018

Codecov Report

Merging #19 into develop will increase coverage by 0.02%.
The diff coverage is 100%.

Impacted file tree graph

@@             Coverage Diff             @@
##           develop      #19      +/-   ##
===========================================
+ Coverage    97.46%   97.48%   +0.02%     
===========================================
  Files            5        5              
  Lines          237      239       +2     
===========================================
+ Hits           231      233       +2     
  Misses           3        3              
  Partials         3        3
Impacted Files Coverage Δ
pool.go 96.22% <100%> (+0.03%) ⬆️
pool_func.go 98.13% <100%> (+0.01%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 92acf74...e7bacd0. Read the comment docs.

@zplzpl
Copy link
Author

zplzpl commented Nov 19, 2018

我自己写了测试示例
重复
ants.NewPoolWithFunc()
然后
进行Resize(0) && Release
但仍发现内存泄漏现象,追溯到了NewTicker没有进行Stop可能导致

flat flat% sum% cum cum%

7168.57kB 77.60% 77.60% 7168.57kB 77.60% time.NewTicker

@zplzpl
Copy link
Author

zplzpl commented Nov 19, 2018

突然看到一个PR有更完善的解决方式,不知道为啥没有PR成功

@panjf2000
Copy link
Owner

另外一个pr跟你大概是完成类似的功能,不过那个failed之后作者就没再更新了,所以就没有merge,你要是有时间不如参考下他的代码再优化下?就放到这个pr里。

@panjf2000 panjf2000 merged commit 639f55c into panjf2000:develop Dec 1, 2018
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

Successfully merging this pull request may close these issues.

2 participants