Changes between Version 5 and Version 6 of OsgDebugging
- Timestamp:
- Aug 3, 2010, 8:56:29 PM (14 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
OsgDebugging
v5 v6 38 38 }}} 39 39 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 :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 mem_log.txt in the application path: 41 41 {{{ 42 42 #!cpp … … 70 70 }}} 71 71 72 inside seperate include file:72 To 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: 73 73 {{{ 74 74 #!cpp … … 83 83 }}} 84 84 85 This include file has to be included in the header file of each class, because the define redefinition of new is file based. 85 This 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 88 class visual_core : public osg::Referenced 89 { 90 #include <leakDetection.h> 86 91 87 todo: output. 92 public: 93 visual_core(osg::ArgumentParser& arguments_); 94 .... 95 } 96 }}} 97 98 99 The output in the logfile looks like: 100 {{{ 101 Detected memory leaks! 102 Dumping 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 115 Object dump complete. 116 }}} 117 The 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 119 If 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!''' 88 128 89 129 90 130 91 todo: false positives92 93 Set your breakpoints,94 131 95 132 == Linux ==