内存与测试
This commit is contained in:
1 parent
efee86fab9
commit
4647022f6f
9 files changed
+36
-11
No files matched your search
@@ -189,6 +189,10 @@ void db_sqlite_init_full(void)
|
||||
if (g_db)
|
||||
{
|
||||
sqlite3_close(g_db);
|
||||
//限制缓存大小 (100KB)
|
||||
sqlite3_exec(g_db, "PRAGMA cache_size = -50;", 0, 0, 0);
|
||||
//设置临时存储为文件模式 (节省内存)
|
||||
sqlite3_exec(g_db, "PRAGMA temp_store = FILE;", 0, 0, 0);
|
||||
g_db = RT_NULL;
|
||||
}
|
||||
return; //
|
||||
@@ -235,6 +239,10 @@ void db_sqlite_init_full(void)
|
||||
}else {
|
||||
if (sqlite3_open(DB_NAME, &g_db) == SQLITE_OK)
|
||||
{
|
||||
//限制缓存大小 (100KB)
|
||||
sqlite3_exec(g_db, "PRAGMA cache_size = -50;", 0, 0, 0);
|
||||
//设置临时存储为文件模式 (节省内存)
|
||||
sqlite3_exec(g_db, "PRAGMA temp_store = FILE;", 0, 0, 0);
|
||||
LOG_D("[DataBase] NAME (%s)",DB_NAME);
|
||||
}
|
||||
}
|
||||
@@ -312,6 +320,10 @@ static void db_sqlite(void *parameter) {
|
||||
return_disabled(&cmd);
|
||||
continue;
|
||||
} else {
|
||||
//限制缓存大小 (100KB)
|
||||
sqlite3_exec(g_db, "PRAGMA cache_size = -50;", 0, 0, 0);
|
||||
//设置临时存储为文件模式 (节省内存)
|
||||
sqlite3_exec(g_db, "PRAGMA temp_store = FILE;", 0, 0, 0);
|
||||
rt_kprintf("Opened database: %s\n", DB_NAME);
|
||||
}
|
||||
}
|
||||
@@ -399,16 +411,28 @@ rt_err_t db_send_command(enum db_cmd_type type, const char* sql, rt_int32_t time
|
||||
return result;
|
||||
}
|
||||
|
||||
extern struct rt_memheap sram_DTCMRAM;
|
||||
static struct rt_thread dat_sqlite_thread;
|
||||
static void *dat_sqlite_stack __attribute__((aligned(4)))= RT_NULL ;
|
||||
/* 线程 */
|
||||
void thread_DB_SQLite(void)
|
||||
{
|
||||
rt_thread_t tid;
|
||||
tid = rt_thread_create("db_sql", db_sqlite, RT_NULL, 1024 *16, 18, 10);
|
||||
rt_err_t db_err;
|
||||
dat_sqlite_stack = rt_memheap_alloc(&sram_DTCMRAM, 1024*16);
|
||||
db_err = rt_thread_init(&dat_sqlite_thread, "db_sql", db_sqlite, RT_NULL,dat_sqlite_stack, 1024*16, 15, 10);
|
||||
if(db_err != RT_EOK)
|
||||
{
|
||||
LOG_D("Failed to create SQLite thread!\n");
|
||||
}
|
||||
rt_thread_startup(&dat_sqlite_thread);
|
||||
|
||||
/* rt_thread_t tid;
|
||||
tid = rt_thread_create("db_sql", db_sqlite, RT_NULL, 1024 *14, 18, 10);
|
||||
|
||||
if (tid != RT_NULL)
|
||||
{
|
||||
rt_thread_startup(tid);
|
||||
}else{
|
||||
LOG_D("Failed to create SQLite thread!\n");
|
||||
}
|
||||
}*/
|
||||
}
|
||||
Reference in new issue
Block a user