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

内存泄漏问题 #8

Open
zccz14 opened this issue Apr 3, 2017 · 0 comments
Open

内存泄漏问题 #8

zccz14 opened this issue Apr 3, 2017 · 0 comments

Comments

@zccz14
Copy link
Owner

zccz14 commented Apr 3, 2017

保存所有的历史记录能保证单例缓存模式的正确性。

单例缓存模式常常能数十倍提升运算效率。

尽管如此,长时间运行下,可能导致内存泄漏问题。

因此,考虑在指标实例上新增一个公开属性,记录被引用的最大窗口长度。

private int _TimeframeSize = 0;
public int TimeframeSize {
  get { return _TimeframeSize; }
  set {
    if (value > _TimeframeSize) {
      _TimeframeSize = value;
      // realloc buffer with new size...
    }
  }
}

TimeframeSize 只可扩大不可减小以保证引用时的正确性。

改用固定大小的循环队列来保存历史数据。

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

1 participant