1. reference counting使得多个等值对象可以共享同一实值,这样不仅简化了heap objects的簿记工作,便于管理内存,而且能够节省空间,提升效率.以下讨论以自实现的String为例.

2. Reference Counting(引用计数)的实现

    基本设计像这样:

class String {
public:
    ...
private:
    struct StringValue { ... }; // 包含引用计数和字符串值
    StringValue *value; // value of this String
};
View Code

相关文章:

  • 2022-02-03
  • 2021-07-25
  • 2021-07-17
  • 2021-12-25
  • 2021-06-15
  • 2021-08-31
  • 2021-08-12
  • 2021-08-04
猜你喜欢
  • 2021-07-20
  • 2021-06-02
  • 2021-05-30
  • 2021-11-16
  • 2021-11-25
  • 2021-09-25
相关资源
相似解决方案