#include <memory_checker.h>
Public Member Functions | |
| void | construct () |
| faux constructor for mallocing. | |
| void | destruct () |
| faux destructor shuts down object. | |
| void | disable () |
| turn off memory checking. | |
| void | enable () |
| turn memory checking back on. | |
| bool | enabled () const |
| reports on whether the memory checker is currently in service or not. | |
| void * | provide_memory (size_t size, char *file, int line) |
| returns a chunk of memory with the "size" specified. | |
| int | release_memory (void *ptr) |
| drops our record for the memory at "ptr". | |
| char * | text_form (bool show_outstanding) |
| returns a newly allocated string with the stats for this object. | |
Provides allocation checking for heap memory for C++. This is used as a replacement for the standard new and delete operations. No object should really need to deal with this class directly; it is hooked in automatically unless the ENABLE_MEMORY_HOOK macro is defined. Generally, release builds should not have this enabled, since it will slow things down tremendously. NOTE: this object can absolutely not be hooked into callstack tracker, since this object implements all c++ memory, including the tracker's. This object will use the backtrace information if it's available.
Definition at line 48 of file memory_checker.h.
| void memory_checker::construct | ( | ) |
faux constructor for mallocing.
Definition at line 359 of file memory_checker.cpp.
References MAXIMUM_HASH_SLOTS.
Referenced by program_wide_memories().
| void memory_checker::destruct | ( | ) |
faux destructor shuts down object.
uhhh free(mem_state);
Definition at line 367 of file memory_checker.cpp.
References NIL, and text_form().
Referenced by hoople_atexit().
| void memory_checker::disable | ( | ) | [inline] |
| void memory_checker::enable | ( | ) | [inline] |
| bool memory_checker::enabled | ( | ) | const [inline] |
reports on whether the memory checker is currently in service or not.
Definition at line 60 of file memory_checker.h.
| void * memory_checker::provide_memory | ( | size_t | size, | |
| char * | file, | |||
| int | line | |||
| ) |
returns a chunk of memory with the "size" specified.
this is the replacement method for the new operator. we will be calling this instead of the compiler provided new. the "file" string should be a record of the location where this is invoked, such as is provided by the __FILE__ macro. the "line" should be set to the line number within the "file", if applicable (use __LINE__).
Definition at line 385 of file memory_checker.cpp.
Referenced by startup_code::HOOPLE_GLOBALS(), and operator new().
| int memory_checker::release_memory | ( | void * | ptr | ) |
drops our record for the memory at "ptr".
this is the only way to remove an entry from our listings so that it will not be reported as a leak. we do not currently gather any info about where the release is invoked. if there was a problem, the returned outcome will not be OKAY.
Definition at line 391 of file memory_checker.cpp.
References common::OKAY.
Referenced by startup_code::HOOPLE_GLOBALS(), and operator delete().
| char * memory_checker::text_form | ( | bool | show_outstanding | ) |
returns a newly allocated string with the stats for this object.
if "show_outstanding" is true, then all outstanding allocations are displayed in the string also. the invoker *must* free the returned pointer.
Definition at line 400 of file memory_checker.cpp.
Referenced by destruct().
1.5.0