CodeGuard Configuration

From RAD Studio
Jump to: navigation, search

Go Up to Tools Menu

Tools > CodeGuard Configuration

Use the CodeGuard Configuration dialog box to specify how the CodeGuard runtime debugger behaves. You can invoke this dialog box by running the cgconfig.exe utility, available in your product installation. If you change any CodeGuard settings in the CodeGuard Configuration dialog box, CodeGuard generates a .cgi configuration file with the same name and directory as your project file.

Note: CodeGuard is available for only C++ projects.
Item Description

Enable (CodeGuard)

Enables or disables CodeGuard.

Stack Fill Frequency

Specifies how frequently CodeGuard fills the uninitialized portion of the runtime stack with a unique byte pattern. Values are:

  • -1 = Never
  • 0 = After every call to a runtime function covered by CodeGuard.
  • n [0...15] = After every 2^n calls to a runtime function covered by CodeGuard. For example, if n is 1, then the stack is filled every other time a runtime function is called.


Reports function and resource usage statistics.

Resource Leaks

Reports resource leaks detected after the application terminates.

Send To OutputDebugString

Uses the OutputDebugString function to send CodeGuard messages to an external debugger.

Append To Log File

Appends the error log to the existing log. When this option is disabled, CodeGuard writes over the existing error log.

Repeated Errors

Reports errors that occur repeatedly per function.

Limit Number Of Error Messages

Limits the number of errors reported. You can specify a maximum value of 65535.

Enable (Error Message Box)

Enables the Error Message Box. If you run a CodeGuard-enabled application outside of RAD Studio, the Error Message Box displays when runtime errors occur.


Specifies the text that appears in the title bar.


Specifies the error message to display.

Read Debug Info

Enables CodeGuard to use the debugging information in your project to point to a source line when a runtime error is reported.

Source Path

If the source code is in a different location from the executable, specify the path (or paths separated by semicolons). CodeGuard checks its own debug source path first, then (if it is running in the IDE) checks the IDE debug source path.

Resource Options

Use the Resource Options page to specify how CodeGuard covers various types of resources.

Item Description


Lists the resource types that CodeGuard can cover, as follows:
Memory Block - Memory managed by malloc and free functions.
Object - Memory managed by new and delete operators.
Object Array - Memory managed by new[] and delete[] operators.
File handle - A file managed by the open and close functions.
File stream - A file managed by the fopen and fclose functions.
Pipe stream - A command processor pipe managed by the _popen and _pclose functions.
Directory stream - A directory managed by the opendir and closedir functions.

Enable Tracking

Enables tracking on the selected resource. Disabling tracking results in lower memory usage and faster execution.

Track Resource Leaks

Reports resource allocations that have no matching deallocations. For example, a leak can be caused by failing to free a file handle before the program terminates.

Report Invalid Handle / Resource Parameters

Reports incorrect usage of resources in function arguments.

Delay Free

Tracks the selected resource after it has been deallocated. When you enable the Delay Free option, CodeGuard marks the each resource once it has been freed and prevents Windows and runtime libraries from attempting to reuse the resource.
Some resources, such as stack memory allocations, cannot be queued for delayed release.

Delay Queue Length

Specifies the number of objects that can be queued for delayed release. You can set a maximum value of 65535 objects.

Maximum Memory Block Size

Specifies the maximum memory block size that CodeGuard can store in the delay queue. You can set a maximum value of 65535 bytes.

Function Options

Use the Function Options page to specify how CodeGuard covers various types of functions.

Item Description


Lists the functions that CodeGuard can track.

Disable Function Tracking

Disables function tracking for the selected functions.

Memory Access Errors

Reports a runtime error if a function uses a pointer to reference invalid memory.

Log Each Call

Reports each call to the selected functions.


Reports situations where your application may be accessing memory beyond the maximum size of a buffer.
Warnings are reported for only the following runtime library functions:
strncmp, strnicmp, strncmpi, _fstrncmp, _fstrnicmp, memcmp, memicmp, _fmemcmp, _fmemicmp, fnmerge, fnsplit, getcurdir.

Function Results Errors

Reports if the selected functions return a value that indicates failure.

Invalid Handle / Resource Parameters

If any of the parameters of the selected functions is a handle or resource identifier, verify that it has been properly allocated and is currently valid.

Set Default Function Options

Displays the Set Default Function Options dialog box, which you can use to view and set the default function options.

Reset To Default Function Options

Applies the default function options to the selected functions.

Ignored Modules

Use the Ignored Modules page to specify modules that you want CodeGuard to skip when it reports errors.

See Also