mco_perfmon_close

Terminates performance monitoring and releases internal resources.

Prototype

    MCO_RET mco_perfmon_close(void);

Arguments

void
No arguments.

Description

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.

Return Codes

MCO_S_OK
Performance Monitor closed successfully.
MCO_E_PERFMON_NOT_INITIALIZED
Performance Monitor was not initialized.
MCO_E_PERFMON_DB_NOT_DETACHED
One or more databases are still attached. Call mco_perfmon_detach() for all attached databases before closing.

Example

    #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;
    }

Files

Header file:
mcoperfmon.h
Source file:
mcoperf.c
Library:
libmcoperf.a