qdb_logmemstats()

Log memory statistics for a database

Synopsis:

#include <qdb/qdb.h>

int qdb_logmemstats( qdb_hdl_t *db );

Arguments:

db
A pointer to the database handle.

Library:

qdb

Description:

This function tells QDB to output memory statistics for the specified database. The information is written to the slog2info log. Note that this is a one-time action—the QDB service won't log any more memory statistics until you call qdb_logmemstats() again.

The information is logged in this format:

SQLite3 Status current(high):  mem=memory_used(memory_used_high),
  page cache=pagecache_used(pagecache_used_high), 
  scratch=scratch_used(scratch_used_high)
where the individual fields have these meanings (and are reported in bytes):
memory_used
The amount of memory currently allocated through sqlite3_malloc() calls
memory_used_high
The maximum amount of memory allocated through sqlite3_malloc() calls up till now (may be higher than the current memory usage if memory has been freed since its peak usage)
pagecache_used
The amount of memory that could not be stored in the page cache buffer and had to be allocated by sqlite3_malloc(). This value includes memory allocations that were too large for the buffer and memory allocations that overflowed when the buffer was full.
pagecache_used_high
The maximum amount of memory that overflowed from the page cache buffer up till this point. This value reflects the peak usage of memory that couldn't fit in the page cache buffer and had to be allocated by sqlite3_malloc().
scratch_used
The amount of memory that could not be stored in the scratch buffer and had to be allocated by sqlite3_malloc(). This value includes memory allocations that were too large for the buffer and memory allocations that failed because no scratch buffer slots were available.
scratch_used_high
The maximum amount of memory that overflowed from the scratch buffer up till this point. This value reflects the peak usage of memory that couldn't fit in the scratch buffer and had to be allocated by sqlite3_malloc().

For the first two fields, QDB calculates their values by reading the SQLITE_STATUS_MEMORY_USED parameter, which is defined by the SQLite3 library to expose memory usage information. The middle two fields are based on the SQLITE_STATUS_PAGECACHE_OVERFLOW parameter, while the last two are based on SQLITE_STATUS_SCRATCH_OVERFLOW. For details on these three parameters (and the others defined by SQLite3), see the Status Parameters page in the online SQLite3 documentation.

Returns:

0
Success.
-1
An error occurred (errno is set).

Classification:

QNX Neutrino

Safety:  
Interrupt handler No
Signal handler No
Thread Yes