Terminates performance monitoring and releases internal resources.
MCO_RET mco_perfmon_close(void);
void
This function shuts down the Performance Monitor, deallocates internal structures, and invalidates the perfmon database. All monitored databases must be detached before calling this function.
After this call, no other perfmon API functions (except
mco_perfmon_init()) can be used until the monitor is reinitialized.
MCO_S_OK
MCO_E_PERFMON_NOT_INITIALIZED
MCO_E_PERFMON_DB_NOT_DETACHED
mco_perfmon_detach() for all attached
databases before closing.
#define PERF_DATABASE_SEGMENT_SIZE (64 << 20) /* 64 MB */
const char* dbName = "SimpleDb";
int main(int argc, char* argv[])
{
mco_db_h db;
MCO_RET rc;
void *perf_memory;
perf_memory = malloc(PERF_DATABASE_SEGMENT_SIZE);
if (!perf_memory) {
/* handle error */
}
rc = mco_perfmon_init(perf_memory, PERF_DATABASE_SEGMENT_SIZE);
if (rc != MCO_S_OK) { /* handle error */ }
rc = mco_perfmon_attach(dbName);
if (rc != MCO_S_OK) { /* handle error */ }
rc = mco_db_connect(dbName, &db);
if (rc != MCO_S_OK) { /* handle error */ }
/* ... perform monitored operations ... */
rc = mco_db_disconnect(db);
if (rc != MCO_S_OK) { /* handle error */ }
rc = mco_perfmon_detach(dbName);
if (rc != MCO_S_OK) { /* handle error */ }
rc = mco_perfmon_close();
if (rc != MCO_S_OK) { /* handle error */ }
free(perf_memory);
return 0;
}