Initializes the Performance Monitor (perfmon) database.
MCO_RET mco_perfmon_init(/*IN*/ void *memory, /*IN*/ mco_size_t memory_size);
memory
memory_size
This function initializes the internal perfmon database used to store runtime performance metrics. The provided memory block must remain valid for the entire duration of monitoring.
This function must be called before any other perfmon API function (e.g.,
mco_perfmon_attach()).
MCO_S_OK
MCO_E_PERFMON_ALREADY_INITIALIZED
#define PERF_DATABASE_SEGMENT_SIZE (64 << 20) /* 64 MB */
int main(int argc, char* argv[])
{
void *perf_memory;
MCO_RET rc;
perf_memory = malloc(PERF_DATABASE_SEGMENT_SIZE);
if (!perf_memory) {
/* handle allocation error */
}
rc = mco_perfmon_init(perf_memory, PERF_DATABASE_SEGMENT_SIZE);
if (rc != MCO_S_OK) {
/* handle initialization error */
}
/* Proceed with mco_perfmon_attach(), etc. */
return 0;
}