简体   繁体   中英

How to detect uninitialized memory (C++, windows, VS2005)?

I'm looking for memory debugger for Windows which will be able to debug uninitialized memory.

There is a code snippet (C++):

class Temp{
public:
 Temp(double d) : m_double(d){};

 double m_double;
 float m_float;
};

int _tmain(int argc, _TCHAR* argv[])
{
 double temp;
 std::cout << temp <<std::endl;

 Temp temp2(2.0);
 std::cout << temp2.m_double <<std::endl;
 std::cout << temp2.m_float <<std::endl;

 int num1, num2;
 num1 = num2 + 1;

 return 0;
}

Desirable features:

  • dynamic memory debugger, not static analysis tool
  • GUI
  • free
  • integration with VS2005
  • simple to use

Tried to use:

  • Rational Purify v.7.0.0.0 build:6274
  • Memory Validator v.5.12
  • cppcheck - worked fine on given snippet but didn't helped on real big project

UPD: it seems that there is no way to find uninitialized memory in release mode with optimizations turned on with dynamic memory debugger. Going to try in debug mode.

In the past I've used Purify for all sorts of memory issues and it works pretty well. Downside is it's $$$$.

If it's at all an option, a Linux port of the backend to use valgrind which is also a great tool.

I think this problem is more related to static code analyzers. I saw such warnings from visual studio with maximum warning level in project settings but I'm not sure about vs2005.

You can also try to use some tools from this question about code analyzers.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM