#include <LeaLeakChecker.h>
Public Types | |
| typedef std::map< std::string, LeaClassMonitor * >::iterator | MapItr |
| typedef std::map< std::string, LeaClassMonitor * >::const_iterator | MapConstItr |
Public Member Functions | |
| virtual | ~LeaLeakChecker () |
| LeaClassMonitor * | GetExistingMonitor (const Char_t *name) const |
| UInt_t | GetNumActive (const Char_t *name=0) const |
| UInt_t | GetNumCreated (const Char_t *name=0) const |
| std::ostream & | Print (std::ostream &os) |
| Bool_t | Add (const Char_t *name, const void *addr) |
| LeaClassMonitor * | GetMonitor (const Char_t *name) |
| void | Reset (const Char_t *name=0) |
| Bool_t | Remove (const Char_t *name, const void *addr) |
Static Public Member Functions | |
| LeaLeakChecker * | Instance () |
Private Member Functions | |
| LeaLeakChecker () | |
Private Attributes | |
| std::map< std::string, LeaClassMonitor * > | fMonitors |
Static Private Attributes | |
| LeaLeakChecker * | fgInstance = 0 |
Friends | |
| struct | Cleaner |
|
|
Definition at line 39 of file LeaLeakChecker.h. Referenced by GetExistingMonitor(), GetNumActive(), GetNumCreated(), and Reset(). |
|
|
Definition at line 38 of file LeaLeakChecker.h. Referenced by Print(), and ~LeaLeakChecker(). |
|
|
Definition at line 318 of file LeaLeakChecker.cxx. References fgInstance, fMonitors, and MapItr. 00318 {
00319
00320
00321 // Purpose: Destructor.
00322
00323 // Arguments:
00324 // None.
00325
00326 // Return: n/a
00327
00328 // Contact: N. West
00329
00330 // Specification:-
00331 // =============
00332
00333 // o Destroy LeaLeakChecker.
00334
00335 // Program Notes:-
00336 // =============
00337
00338 // None.
00339
00340 cout << "LeakChecker shutting down ..." << endl;
00341 for ( MapItr itr = fMonitors.begin();
00342 itr != fMonitors.end();
00343 itr++) {
00344 LeaClassMonitor* mon = (*itr).second;
00345 delete mon;
00346 }
00347 cout << "LeakChecker shutdown complete." << endl;
00348 LeaLeakChecker::fgInstance = 0;
00349
00350 }
|
|
|
Definition at line 290 of file LeaLeakChecker.cxx. References MSG. Referenced by Instance(). 00290 {
00291
00292
00293 // Purpose: Default constructor.
00294
00295 // Arguments:
00296 // None.
00297
00298 // Return: n/a
00299
00300 // Contact: N. West
00301
00302 // Specification:-
00303 // =============
00304
00305 // o Create LeaLeakChecker.
00306
00307 // Program Notes:-
00308 // =============
00309
00310 // None.
00311
00312 MSG("Lea", Msg::kDebug) << "Creating LeaLeakChecker at "
00313 << reinterpret_cast<void*>(this) << endl;
00314
00315 }
|
|
||||||||||||
|
Definition at line 45 of file LeaLeakChecker.cxx. Referenced by NavValidate::Test_1(). 00045 {
00046
00047
00048 // Purpose: Add named object to class monitor.
00049
00050 // Arguments:
00051 // name in String containing class name (can be file name).
00052 // addr in Address of object.
00053
00054 // Return: kTRUE always (reserved for future use).
00055
00056 // Contact: N. West
00057
00058 // Specification:-
00059 // =============
00060
00061 // o Get monitor for class and record object creation.
00062
00063 // Program Notes:-
00064 // =============
00065
00066 // None.
00067
00068 return GetMonitor(name)->Add(addr);
00069
00070 }
|
|
|
Definition at line 75 of file LeaLeakChecker.cxx. References fMonitors, and MapConstItr. Referenced by GetNumActive(), GetNumCreated(), and Reset(). 00076 {
00077
00078
00079 // Purpose: Return monitor for this existing class.
00080
00081 // Arguments:
00082 // name in class name.
00083
00084 // Return: Class Monitor addr, or 0 if none.
00085
00086 // Contact: N. West
00087
00088 // Specification:-
00089 // =============
00090
00091 // o Return the LeaClassMonitor for this class if any.
00092
00093 // Program Notes:-
00094 // =============
00095
00096 // None.
00097
00098
00099 std::string className = name;
00100
00101 // Locate the associated class monitor.
00102 MapConstItr element = fMonitors.find(className);
00103 return ( element != fMonitors.end() ) ? (*element).second : 0;
00104
00105 }
|
|
|
Definition at line 108 of file LeaLeakChecker.cxx. References fMonitors, MSG, and LeaClassMonitor::SetName(). Referenced by Remove(). 00108 {
00109
00110
00111 // Purpose: Return monitor for this class, creating if necessary
00112
00113 // Arguments:
00114 // name in class name or file name.
00115
00116 // Return: Class Monitor add.
00117
00118 // Contact: N. West
00119
00120 // Specification:-
00121 // =============
00122
00123 // o Determine the class name if necessary from the file name.
00124
00125 // o Return, creating if necessary and required, the LeaClassMonitor
00126 // for this class.
00127
00128 // Program Notes:-
00129 // =============
00130
00131 // None.
00132
00133 // Determine the class name from the file name by removing
00134 // leading directory and any trailing extension.
00135
00136 std::string className = name;
00137 if ( className.find(".") < className.size() ) {
00138 UInt_t locSlash = className.rfind("/");
00139 if ( locSlash < className.size() ) className.erase(0,locSlash+1);
00140 className.erase(className.find("."),className.size());
00141 }
00142
00143
00144 // Locate the associated class monitor and set its name if new.
00145 LeaClassMonitor* mon = fMonitors[className];
00146 if ( ! mon ) {
00147 mon = new LeaClassMonitor;
00148 fMonitors[className] = mon;
00149 mon->SetName(className.c_str());
00150 }
00151
00152 MSG("Lea", Msg::kDebug) << "ClassMonitor: "
00153 << className.c_str() << " found at "
00154 << reinterpret_cast<void*> (mon)
00155 << " set size " << fMonitors.size() << endl;
00156
00157 return mon;
00158
00159
00160 }
|
|
|
Definition at line 164 of file LeaLeakChecker.cxx. References fMonitors, GetExistingMonitor(), LeaClassMonitor::GetNumActive(), and MapConstItr. Referenced by Print(), NavValidate::RunAllTests(), and LeaValidate::Test_1(). 00164 {
00165
00166
00167 // Purpose: Return the number of active objects of one or all
00168 // classes.
00169
00170 // Arguments:
00171 // name in Class name string or 0 (default) all classes.
00172
00173 // Return: Return the number of active objects of one or all
00174 // classes.
00175
00176 // Contact: N. West
00177
00178 // Specification:-
00179 // =============
00180
00181 // o Return the number of active objects of one or all classes.
00182
00183 // Program Notes:-
00184 // =============
00185
00186 // None.
00187
00188 // If name supplied, just use, but don't create, it.
00189
00190 if ( name ) {
00191 LeaClassMonitor* mon = GetExistingMonitor(name);
00192 return mon ? mon->GetNumActive() : 0;
00193 }
00194
00195 // No name supplied, use all classs
00196
00197 UInt_t num = 0;
00198 for ( MapConstItr itr = fMonitors.begin();
00199 itr != fMonitors.end();
00200 itr++) num += (*itr).second->GetNumActive();
00201 return num;
00202
00203 }
|
|
|
Definition at line 206 of file LeaLeakChecker.cxx. References fMonitors, GetExistingMonitor(), LeaClassMonitor::GetNumCreated(), and MapConstItr. Referenced by Print(), NavValidate::RunAllTests(), and LeaValidate::Test_1(). 00206 {
00207
00208
00209 // Purpose: Return the number of created objects of one or all
00210 // classes.
00211
00212 // Arguments:
00213 // name in Class name string or 0 (default) all classes.
00214
00215 // Return: Return the number of created objects of one or all
00216 // classes.
00217
00218 // Contact: N. West
00219
00220 // Specification:-
00221 // =============
00222
00223 // o Return the number of created objects of one or all classes.
00224
00225 // Program Notes:-
00226 // =============
00227
00228 // None.
00229
00230 // If name supplied, just use, but don't create, it.
00231
00232 if ( name ) {
00233 LeaClassMonitor* mon = GetExistingMonitor(name);
00234 return mon ? mon->GetNumCreated() : 0;
00235 }
00236
00237 // No name supplied, use all classs
00238
00239 UInt_t num = 0;
00240 for ( MapConstItr itr = fMonitors.begin();
00241 itr != fMonitors.end();
00242 itr++) num += (*itr).second->GetNumCreated();
00243 return num;
00244
00245 }
|
|
|
Definition at line 248 of file LeaLeakChecker.cxx. References LeaLeakChecker::Cleaner::ClassIsUsed(), fgInstance, LeaLeakChecker(), and MSG. Referenced by DbmModule::CheckMemory(), NavValidate::RunAllTests(), and LeaValidate::Test_1(). 00248 {
00249
00250
00251 // Purpose: Return a pointer to the sole instance of the LeaLeakChecker.
00252
00253 // Arguments:
00254 // None
00255
00256 // Return: A pointer to the LeaLeakChecker.
00257
00258 // Contact: N. West
00259
00260 // Specification:-
00261 // =============
00262
00263 // o Return a pointer to the sole instance of the LeaLeakChecker.
00264
00265 // Program Notes:-
00266 // =============
00267
00268 // None.
00269
00270 if ( ! fgInstance ) {
00271
00272 // Helper class to handle delete
00273 static LeaLeakChecker::Cleaner c;
00274 c.ClassIsUsed();
00275
00276 fgInstance = new LeaLeakChecker();
00277
00278 MSG("Lea",Msg::kWarning) << "\n\n\n"
00279 << " WARNING: The LeakChecker package has been activated.\n"
00280 << " ******* This can seriously degrade performance and should\n"
00281 << " only be used for development and never production !!!\n\n\n";
00282
00283 }
00284
00285 return fgInstance;
00286
00287 }
|
|
|
Definition at line 354 of file LeaLeakChecker.cxx. References fMonitors, GetNumActive(), GetNumCreated(), MapItr, and LeaClassMonitor::Print(). Referenced by operator<<(). 00354 {
00355
00356
00357 // Purpose: Display current status of Leak Checker on ostream.
00358
00359 // Arguments:
00360 // os in ostream to display on.
00361
00362 // Return: Update ostream.
00363
00364 // Contact: N. West
00365
00366 // Specification:-
00367 // =============
00368
00369 // o Display current status of Leak Checker on ostream.
00370
00371 // Program Notes:-
00372 // =============
00373
00374 // None.
00375
00376 os << "Currently " << fMonitors.size()
00377 << " classes are being monitored. " << endl
00378 << "There are "
00379 << GetNumActive() << " active objects of a total "
00380 << GetNumCreated() << " created." << endl
00381 << "Breakdown by class:-" << endl;
00382
00383 for ( MapItr itr = fMonitors.begin();
00384 itr != fMonitors.end();
00385 itr++) {
00386 LeaClassMonitor* mon = (*itr).second;
00387 mon->Print(os);
00388 }
00389
00390 return os;
00391
00392 }
|
|
||||||||||||
|
Definition at line 434 of file LeaLeakChecker.cxx. References GetMonitor(), and LeaClassMonitor::Remove(). 00434 {
00435
00436
00437 // Purpose: Remove named object to class monitor.
00438
00439 // Arguments:
00440 // name in String containing class name (can be file name).
00441 // addr in Address of object.
00442
00443 // Return: kTRUE always (reserved for future use).
00444
00445 // Contact: N. West
00446
00447 // Specification:-
00448 // =============
00449
00450 // o Get monitor for class and record object destruction.
00451
00452 // Program Notes:-
00453 // =============
00454
00455 // None.
00456
00457 return GetMonitor(name)->Remove(addr);
00458
00459 }
|
|
|
Definition at line 395 of file LeaLeakChecker.cxx. References fMonitors, GetExistingMonitor(), MapConstItr, and LeaClassMonitor::Reset(). Referenced by NavValidate::RunAllTests(), and LeaValidate::Test_1(). 00395 {
00396
00397
00398 // Purpose: Clear the number of objects of one or all classes.
00399
00400 // Arguments:
00401 // name in Class name string or 0 (default) all classes.
00402
00403 // Return: None.
00404
00405 // Contact: N. West
00406
00407 // Specification:-
00408 // =============
00409
00410 // o Reseet the number of objects of one or all classes.
00411
00412 // Program Notes:-
00413 // =============
00414
00415 // None.
00416
00417 // If name supplied, just use, but don't create, it.
00418
00419 if ( name ) {
00420 LeaClassMonitor* mon = GetExistingMonitor(name);
00421 if ( mon ) mon->Reset();
00422 }
00423
00424 // No name supplied, use all classs
00425
00426 for ( MapConstItr itr = fMonitors.begin();
00427 itr != fMonitors.end();
00428 itr++) (*itr).second->Reset();
00429
00430 }
|
|
|
Definition at line 70 of file LeaLeakChecker.h. |
|
|
Definition at line 37 of file LeaLeakChecker.cxx. Referenced by Instance(), LeaLeakChecker::Cleaner::~Cleaner(), and ~LeaLeakChecker(). |
|
|
Definition at line 76 of file LeaLeakChecker.h. Referenced by GetExistingMonitor(), GetMonitor(), GetNumActive(), GetNumCreated(), Print(), Reset(), and ~LeaLeakChecker(). |
1.3.9.1