Dr.Memory发现错误:不知道如何修复它

时间:2013-07-25 09:21:25

标签: c++ visual-studio-2008 memory-leaks dr-memory

对于博士发现的这种错误,我能做些什么吗?存储器?

Error #xxx: INVALID HEAP ARGUMENT: allocated with operator new, freed with free
std::_DebugHeapDelete<std::locale>
    ??:0
std::ios_base::_Ios_base_dtor
    ??:0
std::ios_base::~ios_base
    ??:0
std::basic_ios<char,std::char_traits<char> >::~basic_ios<char,std::char_traits<char> >
    ??:0
std::basic_stringstream<char,std::char_traits<char>,std::allocator<char> >::`vbase destructor'
    ??:0
some_namespace::some_function()
    some_source.cpp(60):

Note: memory was allocated here:
Note: std::ios_base::_Init
    ??:0
Note: std::basic_ios<char,std::char_traits<char> >::init
    ??:0
Note: std::basic_istream<char,std::char_traits<char> >::basic_istream<char,std::char_traits<char> >
    ??:0
Note: std::basic_iostream<char,std::char_traits<char> >::basic_iostream<char,std::char_traits<char> >
    ??:0
Note: std::basic_stringstream<char,std::char_traits<char>,std::allocator<char> >::basic_stringstream<char,std::char_traits<char>,std::allocator<char> >
    ??:0
Note: some_namespace::some_function()
Note:     some_source.cpp(30):

代码如下所示(为方便起见添加了行):

string some_function( int i, int j, int k )
{
30:  stringstream ss;
(...)
     std::string res = ss.str();
(...)
60:  return res;    
}

编译器是VisualStudio 2008 sp1,语言本机c ++。当然,在将.rdbuf() - &gt; str()改为简单的.str()之后 - 没有任何改变,错误仍然存​​在。

1 个答案:

答案 0 :(得分:1)

我认为这是记忆博士的一个错误,

正如下面的代码中所说的“无效的争论,以释放0x0bdd3048”

template<typename CharType>
class MessageBuilder
{
   (...)
          {
            std::basic_ostringstream<CharType> ss;
            ss << msg;
            msg_ += ss.str();
-->       }
};