Looking for a quick and dirty way to identify the calling constructor object (or any function, for that matter) I am writing macros to help identify memory leaks by resetting the pointers thisto OutputDebugString.
this
OutputDebugString
Knowing where ctor and dtor were called from will help identify the problem.
Th \ 0
If you are using visual studio, you can attach a debugger and, instead of having a breakpoint, has a trace point. You do this by right-clicking the breakpoint and selecting When Hit.... Then select to print the message, including the stack trace. This message will be sent to the output panel, and you can analyze all calls in your free time.
When Hit...
hit-point http://lanzkron.googlepages.com/hit-point.jpg
The best way I can come up with is to run your program in the debugger and set a breakpoint in the constructor. Then view the call stack.
, , . .
, , , , , , win32 API. , / , , std::vector<std::string>. ( RAII , push_back pop_back)
std::vector<std::string>
push_back
pop_back
, (OutputDebugString). , api StackWalk64 stacktrace. . ++ (MSVC).
(BoundsChecker ..).
, ++ . , valgrind , . RAII ( ).
valgrind
gcc? ?
Linux, Valgrind , , . ++.
Windows? Visual Leak Detector .
RAII .
, . MMGR.
ctor dtor? ++, , , , , , .
, / , /.
. Win32; ?
.
, , , . , , .
, ? , ( ), . std Win32, , , , (.. - ). , , , , , . , , ... , , eip , , , - ():
call label label: pop eax mov [address of next array entry], eax
g++, . , , gcov.
, , .
, , , , . . , lcov, !
Thank you all for your feedback. setting a breakpoint in ctor is not an option due to hundreds of calls to new objects even during the short program life cycle.
Tracing macros in ctor and dtor did the trick.
Visual leak detector and Stackwalk64 look very promising
also found AfxDumpStack (AFX_STACK_DUMP_TARGET_ODS); // OutputDebugStringbut it is VERY noisy
Source: https://habr.com/ru/post/1702686/More articles:Write a visual studio project from code - c #What is the best way to send emails from a web server to simulate backups and spam? - smtphttps://translate.googleusercontent.com/translate_c?depth=1&pto=aue&rurl=translate.google.com&sl=ru&sp=nmt4&tl=en&u=https://fooobar.com/questions/1702683/authorization-authentication-when-doing-ajax-jquery-calls-to-net-web-services-asmx-wcf-etc-what-do-i-need-to-know&usg=ALkJrhhnqk6H_AiGbyKiQnYro_L9WBoHWwWhere is ODBC File DSN in Windows Vista - windowsCSS background url() не отображается в IE, работает в FF/Safari - cross-browserСкопируйте файл из одного каталога в другой по дате - sqlКак проинструктировать веб-браузеры НЕ кэшировать страницы? - httpWhat is the best CSS trick to reduce HTML code? - htmlHow to get the application pool name for a specific IIS6 website programmatically? C # - c #Memory Leak in TDictionary - Problems with a Workaround? - memory-leaksAll Articles