MainLicence GeneratorContact UsAbout 

2.1 - Integrating the SDK

The Oso Memory Profiler is an intrusive profiler. That is to say, you must compile the SDK into your application and call the profiler functions to collect profile data. This page provides an overview of what is included in the SDK, and how you can integrate it into your application.

The Oso Memory Profiler SDK consists of a collection of C header and source files, and a C++ header file. These files are installed to the following location:

C:\ProgramData\Oso\MemoryProfiler\SDK

The exact files you should include in your application depend on the platform your application is running on. The files you will need for each supported platform are listed below:

Windows

  • OsoMemoryProfiler.h
  • OsoMemoryProfiler.c

  • OsoMP_Callstacks.c
  • OsoMP_Callstacks_Win32.c
  • OsoMP_File_Win32.c
  • OsoMP_Network.c
  • OsoMP_Utils_Win32.c
  • OsoMP_Internal.h

MacOS, Android (Native), and Linux

  • OsoMemoryProfiler.h
  • OsoMemoryProfiler.c

  • OsoMP_Callstacks.c
  • OsoMP_Callstacks_Clang.c
  • OsoMP_File.c
  • OsoMP_Network.c
  • OsoMP_Utils_Posix.c
  • OsoMP_Internal.h
It should be noted that Linux support is untested, however our work to support both MacOS and Android should, in theory, mean that profiling Linux applications is viable at this time.

As you may have noticed, the top two files OsoMemoryProfiler.h, and OsoMemoryProfiler.c are always included on all platforms. These two files contain the public API for the SDK. All other files provide internal helper services.

The file OsoMP_Callstacks_Clang.c is primarily designed to work with the clang compiler. However the functionality used is based on clang's backwards compatibility with GCC, so it should be possible to use this with GCC as well.

If you are writing a C++ application, the Oso Memory Profiler SDK also comes with a single source file that provides global new and delete implementations that you can use as a quick and easy way to get started:
Once you have the SDK compiling, you will need to implement an initialise function that will be called by the SDK when processing the first memory request. You should note that for most applications, this callback function will be called before your first global variable is initialised, and long before main is reached. The signature of this function should be as follows:

void OsoMP_InitialiseCallback( void );
Exactly what this function does depends on whether you wish to use local or remote profiling (or both at the same time), but ultimately it should call OsoMP_Initialise to initialise the profiler.

In addition to initialising the profiler, you also need to stop profiling (and flush any cached profile data) when your application exits. The function OsoMP_Closedown is used to do this.