Menu

CppCheck Memory Leak checking

2016-06-30
2016-07-07
  • Nilay Srivastava

    If a pointer is declared in one file(say A.h) and memory is allocated to it(be it "new" or "malloc") in another file(say A.cpp, that includes A.h) but not deallocated(be it "delete" or "free"), then cppcheck is not able to detect the memory leak.
    Whereas if the pointer is declared and alocated memory to in the same file, then the memory leak is detected by cppcheck.
    Do I need to configure cppcheck somehow to resolve this issue?
    I am using cppcheck 1.67 integrated with Code::Blocks.

     
  • Mr. X

    Mr. X - 2016-07-07

    First of all, I would recommend to use stand-alone cppcheck and a recent version (1.74). If cppcheck can find the include file there is a chance that the issue is detected; however, there are limitations to analysis of global variables.

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.