aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorVadim Yanitskiy <axilirator@gmail.com>2018-07-31 22:40:30 +0700
committerVadim Yanitskiy <axilirator@gmail.com>2019-07-30 17:15:17 +0000
commitfbd736ef3745a19d085823b5c81632100db5162f (patch)
tree2874c8c0ad858c7a777300a3b8f55346c6034b22 /tests
parentdc30154fdfd4fec2094d722042bf8704f6faaafc (diff)
src/db.c: integrate SQLite3 with talloc allocator
This change introduces an optional feature that allows to make SQLite3 use talloc for all internal allocations. This would facilitate finding memleaks. OsmoHLR needs to be configured with '--enable-sqlite-talloc'. full talloc report on 'OsmoHLR' (total 292168 bytes in 449 blocks) struct osmo_gsup_server contains 162 bytes in 3 blocks (ref 0) ... struct db_context contains 288407 bytes in 420 blocks (ref 0) hlr.db contains 7 bytes in 1 blocks (ref 0) SQLite3 contains 288192 bytes in 418 blocks (ref 0) db.c:95 contains 48 bytes in 1 blocks (ref 0) db.c:95 contains 2 bytes in 1 blocks (ref 0) ... Unfortunately, old SQLite3 versions (such as 3.8.2) run out of memory when trying to initialize a new database: DDB ERROR db.c:88 (7) statement aborts at 3: [] DDB ERROR db.c:420 Unable to set Write-Ahead Logging: out of memory DDB ERROR db.c:88 (7) statement aborts at 3: [] DDB ERROR db.c:238 Unable to prepare SQL statement 'SELECT name FROM sqlite_master WHERE type='table' AND name=?' ... I've noticed a huge difference in heap usage footprint compared to generic malloc. At the same time, the recent versions (at least 3.24.0), work just fine. Change-Id: Icfe67ed0f063b63e6794f9516da3003d01cf20a7
Diffstat (limited to 'tests')
-rw-r--r--tests/db/Makefile.am4
1 files changed, 4 insertions, 0 deletions
diff --git a/tests/db/Makefile.am b/tests/db/Makefile.am
index fa925f8..5730937 100644
--- a/tests/db/Makefile.am
+++ b/tests/db/Makefile.am
@@ -36,6 +36,10 @@ db_test_LDADD = \
$(SQLITE3_LIBS) \
$(NULL)
+if DB_SQLITE_DEBUG
+db_test_LDADD += $(top_builddir)/src/db_debug.o
+endif
+
.PHONY: db_test.db update_exp manual manual-nonverbose manual-gdb
db_test.db:
rm -f db_test.db