Changes between Version 5 and Version 6 of OsgDebugging


Ignore:
Timestamp:
Aug 3, 2010, 8:56:29 PM (14 years ago)
Author:
Torben Dannhauer
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • OsgDebugging

    v5 v6  
    3838}}}
    3939
    40 Inside the main() function wo have to specify in detail how to track the memory. Because the MSVC debug windows is quite slow for large outputs, we use the file output:
     40Inside the main() function wo have to specify in detail how to track the memory. Because the MSVC debug windows is quite slow for large outputs, we use the file output mem_log.txt in the application path:
    4141{{{
    4242#!cpp
     
    7070}}}
    7171
    72 inside seperate include file:
     72To enable the debug output with line numbers, we have to redefine the new operator. Because preprocessor #define commands work an a per file base, we have to repeat the redefinition in each headerfile (inside the class). The header file contains the following code:
    7373{{{
    7474#!cpp
     
    8383}}}
    8484
    85 This include file has to be included in the header file of each class, because the define redefinition of new is file based.
     85This include file has to be included in the header file of each class, because the define redefinition of new is file based. The following lines show the source fiel preparation with the headerfiel above:
     86{{{
     87#!cpp
     88class visual_core : public osg::Referenced
     89{
     90        #include <leakDetection.h>
    8691
    87 todo: output.
     92public:
     93        visual_core(osg::ArgumentParser& arguments_);
     94....
     95}
     96}}}
     97
     98
     99The output in the logfile looks like:
     100{{{
     101Detected memory leaks!
     102Dumping objects ->
     103{4436425} normal block at 0x3135E588, 24 bytes long.
     104 Data: <    p 51     *  > 80 80 10 01 70 E2 35 31 80 80 10 01 10 2A 00 00
     105{4436424} normal block at 0x3135E530, 24 bytes long.
     106 Data: <  51  51  51l   > 10 E1 35 31 B8 E0 35 31 D8 E4 35 31 6C F2 02 00
     107{4436423} normal block at 0x3135E4D8, 24 bytes long.
     108 Data: <    0 51     E  > 80 80 10 01 30 E5 35 31 80 80 10 01 B4 45 04 00
     109{4436422} normal block at 0x3135E480, 24 bytes long.
     110
     111...
     112
     113{142} normal block at 0x011059A8, 192 bytes long.
     114 Data: < ?4^            > D4 3F 34 5E 00 00 00 00 01 00 00 00 00 00 00 00
     115Object dump complete.
     116}}}
     117The number in front of every entry is the number of the memory allocation which could be used to identify the allocation and to set breakpoints only for this operation.
     118
     119If any true memory loss inside the code if found, it is possible to identify it on the source file specification  and line number like this entry:
     120{{{
     121{3756} normal block at 0x012F4AE8, 32 bytes long.
     122 Data: <osgPlugins-2.9.9> 6F 73 67 50 6C 75 67 69 6E 73 2D 32 2E 39 2E 39
     123.\src\core\visual_core.cpp(50) : {3668} normal block at 0x012EFBE8, 8000 bytes long.
     124 Data: <                > CD CD CD CD CD CD CD CD CD CD CD CD CD CD CD CD
     125}}}
     126
     127'''Memory leaks are only reported with linenumbers if you redefine the new operator via the include file!'''
    88128
    89129
    90130
    91 todo: false positives
    92 
    93 Set your breakpoints,
    94131
    95132== Linux ==