On 03/23/2017 10:00 PM, Subramaniyan, Ganesan (G.) wrote:
Hi,
We are facing dynamic memory pool corruption issue while using SQLite. Based on
our investigation we suspect SQLite freeing memory bypassing the memory
management API'S registered as below.
We have registered the memory allocation routines as below.
static const sqlite3_mem_methods mqxmem = {
mqxMalloc,
mqxFree,
mqxRealloc,
mqxSize,
mqxRoundup,
mqxInit,
mqxShutdown,
NULL
};
sqlite3_config(SQLITE_CONFIG_MALLOC, &mqxmem);
Despite this, is there any sort of configurations by which SQLite might still
use its own or standard library APIs to allocate/reallocate or free the memory,
bypassing the memory management APIs registered above?
No. Following a successful call to sqlite3_config() SQLite allocates and
frees memory using the configured routines exclusively[1]. There are no
direct calls to malloc()/free() or similar in the library.
Are you checking the return value of sqlite3_config()? If
sqlite3_initialize() or any other sqlite3_*() function has already been
called when sqlite3_config() is invoked it will fail and the memory
allocation routines will not be configured.
https://sqlite.org/c3ref/config.html
What symptoms are you seeing that suggest SQLite is bypassing your
memory allocation functions?
Dan.
[1] It may also make use of static buffers supplied by calls to
sqlite3_config(SQLITE_CONFIG_HEAP), CONFIG_PAGECACHE or CONFIG_SCRATCH,
but I'm guessing you have made no such calls. Most apps do not.
We are using SQLite version 3.7.10 running on Freescale MQX hosted on ARM A5
Cortex processor.
We have enabled SQLITE_ENABLE_MEMORY_MANAGEMENT configuration and using
sqlite3_release_memory()<https://www.sqlite.org/c3ref/release_memory.html> very
often, after every fetch/write operations.
Thanks & Regards,
Ganesan.S
_______________________________________________
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
_______________________________________________
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users