What's New in Oracle® Solaris Studio 12.4

Exit Print View

Updated: December 2014

New Discover APIs

Six new Discover APIs were added to the Code Analysis tools. When your application is using too much memory, you can use these APIs to pinpoint where the memory leaks are happening before the application ends. The APIs can also locate all the memory blocks in use.

These APIs can be inserted directly to the application source or called during a debugging session to report the new and total memory usage, and the new and total memory leaks, at any time, from any start point. They are especially useful for long-running or always-running enterprise server applications.

The following APIs were added to the Code Analysis tools:

  • discover_report_all_inuse()

  • discover_mark_all_inuse_as_reported()

  • discover_report_unreported_inuse()

  • discover_report_all_leaks()

  • discover_mark_all_leaks_as_reported()

  • discover_report_unreported_leaks()

Example 4-1  Using the discover_report_unreported_leaks() API

The following is an example of using the discover_report_unreported_leaks() API, after running the binary with Discover and using dbx to execute the API.

%discover -w - a.out
% dbx a.out
 (dbx) stop in foo2
 (dbx) run
 (dbx) call discover_report_unreported_leaks()
 ******** discover_report_unreported_leaks() Report ********

  1 allocation at 1 location left on the heap with a total size of 1 byte

      LEAK 1: 1 allocation with total size of 1 byte
          foo1() + 0x5e  <api_example.c:7>
                   4:    #include <discoverAPI.h>
                   6:    void foo1() {
                   7:=>    char *x = (char *) malloc(sizeof(char));
                   8:      *x = 'a';
                   9:      printf("x = %c\n", *x);
                  10:      /*free(x);*/
          main() + 0x1a  <api_example.c:21>
                  18:    }
                  20:    int main() {
                  21:=>    foo1();
                  22:      foo2();
                  23:      return 0;
                  24:    }
          _start() + 0x71


For more information on each of the Discover APIs and how to use them, see the Discover header file and discover APIs in Oracle Solaris Studio 12.4: Discover and Uncover User’s Guide .