Version: 3.0.3
wxDebugContext Class Reference

#include <wx/memory.h>

Detailed Description

A class for performing various debugging and memory tracing operations.

Full functionality (such as printing out objects currently allocated) is only present in a debugging build of wxWidgets, i.e. if the WXDEBUG symbol is defined. wxDebugContext and related functions and macros can be compiled out by setting wxUSE_DEBUG_CONTEXT to 0 is setup.h

Library:  wxBase
Category:  Debugging
See also
Debugging

Static Public Member Functions

static int Check (bool checkAll=false)
 Checks the memory blocks for errors, starting from the currently set checkpoint. More...
 
static bool Dump ()
 Performs a memory dump from the currently set checkpoint, writing to the current debug stream. More...
 
static bool GetCheckPrevious ()
 Returns true if the memory allocator checks all previous memory blocks for errors. More...
 
static bool GetDebugMode ()
 Returns true if debug mode is on. More...
 
static int GetLevel ()
 Gets the debug level (default 1). More...
 
static bool PrintClasses ()
 Prints a list of the classes declared in this application, giving derivation and whether instances of this class can be dynamically created. More...
 
static bool PrintStatistics (bool detailed=true)
 Performs a statistics analysis from the currently set checkpoint, writing to the current debug stream. More...
 
static void SetCheckPrevious (bool check)
 Tells the memory allocator to check all previous memory blocks for errors. More...
 
static void SetCheckpoint (bool all=false)
 Sets the current checkpoint: Dump and PrintStatistics operations will be performed from this point on. More...
 
static void SetDebugMode (bool debug)
 Sets the debug mode on or off. More...
 
static void SetLevel (int level)
 Sets the debug level (default 1). More...
 
static void SetShutdownNotifyFunction (wxShutdownNotifyFunction func)
 Installs a function to be called at the end of wxWidgets shutdown. More...
 

Member Function Documentation

static int wxDebugContext::Check ( bool  checkAll = false)
static

Checks the memory blocks for errors, starting from the currently set checkpoint.

Returns
Returns the number of errors, so a value of zero represents success. Returns -1 if an error was detected that prevents further checking.
static bool wxDebugContext::Dump ( )
static

Performs a memory dump from the currently set checkpoint, writing to the current debug stream.

Calls the Dump member function for each wxObject derived instance.

Returns
true if the function succeeded, false otherwise.
static bool wxDebugContext::GetCheckPrevious ( )
static

Returns true if the memory allocator checks all previous memory blocks for errors.

By default, this is false since it slows down execution considerably.

See also
SetCheckPrevious()
static bool wxDebugContext::GetDebugMode ( )
static

Returns true if debug mode is on.

If debug mode is on, the wxObject new and delete operators store or use information about memory allocation. Otherwise, a straight malloc and free will be performed by these operators.

See also
SetDebugMode()
static int wxDebugContext::GetLevel ( )
static

Gets the debug level (default 1).

The debug level is used by the wxTraceLevel function and the WXTRACELEVEL macro to specify how detailed the trace information is; setting a different level will only have an effect if trace statements in the application specify a value other than one.

Deprecated:
This is obsolete, replaced by wxLog functionality.
See also
SetLevel()
static bool wxDebugContext::PrintClasses ( )
static

Prints a list of the classes declared in this application, giving derivation and whether instances of this class can be dynamically created.

See also
PrintStatistics()
static bool wxDebugContext::PrintStatistics ( bool  detailed = true)
static

Performs a statistics analysis from the currently set checkpoint, writing to the current debug stream.

The number of object and non-object allocations is printed, together with the total size.

Parameters
detailedIf true, the function will also print how many objects of each class have been allocated, and the space taken by these class instances.
See also
PrintStatistics()
static void wxDebugContext::SetCheckpoint ( bool  all = false)
static

Sets the current checkpoint: Dump and PrintStatistics operations will be performed from this point on.

This allows you to ignore allocations that have been performed up to this point.

Parameters
allIf true, the checkpoint is reset to include all memory allocations since the program started.
static void wxDebugContext::SetCheckPrevious ( bool  check)
static

Tells the memory allocator to check all previous memory blocks for errors.

By default, this is false since it slows down execution considerably.

See also
GetCheckPrevious()
static void wxDebugContext::SetDebugMode ( bool  debug)
static

Sets the debug mode on or off.

If debug mode is on, the wxObject new and delete operators store or use information about memory allocation. Otherwise, a straight malloc and free will be performed by these operators.

By default, debug mode is on if WXDEBUG is defined. If the application uses this function, it should make sure that all object memory allocated is deallocated with the same value of debug mode. Otherwise, the delete operator might try to look for memory information that does not exist.

See also
GetDebugMode()
static void wxDebugContext::SetLevel ( int  level)
static

Sets the debug level (default 1).

The debug level is used by the wxTraceLevel function and the WXTRACELEVEL macro to specify how detailed the trace information is; setting a different level will only have an effect if trace statements in the application specify a value other than one.

Deprecated:
This is obsolete, replaced by wxLog functionality.
See also
GetLevel()
static void wxDebugContext::SetShutdownNotifyFunction ( wxShutdownNotifyFunction  func)
static

Installs a function to be called at the end of wxWidgets shutdown.

It will be called after all files with global instances of wxDebugContextDumpDelayCounter have run their destructors.

The shutdown function must be take no parameters and return nothing.