昨天晚上,我徒弟跑过来讲,他的程序的内存占用居高不下,愿意是std::map的clear()没有效果。于是我让他用erase(begin,end); 试试也不行。

代码如下:

void release_map(void)
{
    map<int,string> testmap;
    for(int i=0; i<1000000; i++)
    {
        testmap.insert(make_pair(i,"abc"));
    }
    testmap.clear();
}

int main()
{
    release_map();
    while(1)
    {
        sleep(1);
    }
return 0;
}
View Code

相关文章:

  • 2022-12-23
  • 2021-11-16
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-01-07
猜你喜欢
  • 2022-12-23
  • 2021-10-18
  • 2022-12-23
  • 2021-08-25
  • 2021-05-17
  • 2022-12-23
相关资源
相似解决方案