Xenogenesis
Xenogenesis

Reputation: 390

Size of a SQLite3 in memory database

I have a SQLite3 in memory database:

sqlite3* database;
sqlite3_open(":memory:", &database);

Is it possible to get the exact size of the database in memory?

I need to send the database to a client without saving it on a disk and have to tell him the size.

Upvotes: 1

Views: 1657

Answers (2)

Pedro Alves
Pedro Alves

Reputation: 1728

You can use sqlite3_memory_used() for this.

The sqlite3_memory_used() routine returns the number of bytes of memory currently outstanding (malloced but not freed).

http://www.sqlite.org/c3ref/memory_highwater.html

Upvotes: 1

Anton Kovalenko
Anton Kovalenko

Reputation: 21507

Use pragma page_count (multiplied by pragma page_size).

Upvotes: 2

Related Questions