C++'s std::string pools, debug builds? std::string and valgrind problems

前端 未结 6 669
旧巷少年郎
旧巷少年郎 2021-01-11 16:38

I have a problem with many valgrind warnings about possible memory leaks in std::string, like this one:

120 bytes in 4 blocks are possibly lost in loss recor         


        
6条回答
  •  长情又很酷
    2021-01-11 17:10

    If I remember correctly, many STL allocators implement some kind of retention of memory. IE they do not release the memory allocated right away, but keep it around and reuse it. I certainly had many false positives in valgrind coming from memory allocated by my STL implementation.

    The best way I have found to deal with the problem is (simply) to use the suppression file.

提交回复
热议问题