Oracle® Solaris Studio 12.4: Debugging a Program With dbx

Exit Print View

Updated: January 2015
 
 

Finding Memory Access Problems and Memory Leaks

Runtime checking consists of two parts: memory access checking, and memory use and leak checking. Access checking checks for improper use of memory by the debugged application. Memory use and leak checking involves keeping track of all the outstanding heap space and then on demand or at termination of the program, scanning the available data spaces and identifying the space that has no references.

Memory access checking, and memory use and leak checking, are enabled with the check command. To enable memory access checking only:

(dbx) check -access

To enable memory use and memory leak checking:

(dbx) check -memuse

After enabling the types of runtime checking you want, run your program. The program runs normally but slowly because each memory access is checked for validity just before it occurs. If dbx detects invalid access, it displays the type and location of the error. You can then use dbx commands such as the where command to display the current stack trace or the print command to examine variables.


Note - You cannot use runtime checking on an application that is a mixture of Java code and C JNI code or C++ JNI code.

For detailed information about using runtime checking, see Chapter 9, Using Runtime Checking.