# mco_disk_cache_usage
RT

> Estimate the amount of disk cache memory used by persistent objects of each class.

### Prototype

        MCO_RET mco_disk_cache_usage(
            /*IN*/  mco_db_h db,
            /*OUT*/ mco_size_t *classes
        );

### Arguments

`db`
Database connection handle.
`classes`
Pointer to an array of `mco_size_t` values, where each element corresponds to a class in the database dictionary. The function writes the estimated cached size (in bytes) for each class into this array. The array must be large enough to hold `n_class_codes` elements (typically `MCO_MAX_CLASSES`).

### Description

> This function scans all pages of persistent storage that are currently loaded in the disk cache and estimates the total memory footprint of cached objects for each class.

> It uses the `PAGE_PROBE` flag during page iteration, which means it only considers pages that are already present in the cache — pages not loaded into memory are skipped.

> The function is primarily intended for diagnostic and monitoring purposes

> Important limitations:

> - The reported size is an estimate, not an exact measurement.
> - For objects spanning multiple pages, the function assumes the entire object is in memory if any of its pages are cached.
> - For fixed-size objects, it sums the size of allocated objects on cached pages but does not account for internal fragmentation or free space within fixed-record allocator pages.
> - Only persistent (disk-based) classes are considered; in-memory classes are ignored.

### Return Codes

`MCO_S_OK`
Cache usage statistics successfully gathered.
Other error codes
May include I/O errors or internal system errors during page iteration.

### Files

Header file:
mco.h
Source file:
mcodisk.c
Library:
libmcolib.a