Of Memory Management, Heap Corruption, and C++

后端 未结 12 1870
半阙折子戏
半阙折子戏 2020-12-01 02:54

So, I need some help. I am working on a project in C++. However, I think I have somehow managed to corrupt my heap. This is based on the fact that I added an std::stri

12条回答
  •  爱一瞬间的悲伤
    2020-12-01 03:53

    Some places to start:

    If you're on windows, and using visual C++6 (I hope to god nobody still uses it these days) it's implentation of std::string is not threadsafe, and can lead to this kind of thing.

    Here's an article I found which explains a lot of the common causes of memory leaks and corruption.

    At my previous workplace we used Compuware Boundschecker to help with this. It's commercial and very expensive, so may not be an option.

    Here's a couple of free libraries which may be of some use

    http://www.codeguru.com/cpp/misc/misc/memory/article.php/c3745/

    http://www.codeproject.com/KB/cpp/MemLeakDetect.aspx

    Hope that helps. Memory corruption is a sucky place to be in!

提交回复
热议问题