Skip to content

Conversation

@CV-Bowen
Copy link
Contributor

@CV-Bowen CV-Bowen commented Jan 4, 2024

Page cell table is alloced in lhInstallCell() when pPage->nCell < 1, but not free the cell table when pPage->nCell == 0.

So when in the next call of lhInstallCell() and pPage->nCell == 0, cell table is mallcoed again and old cell table not freed. Memory leak happends.

Memory Leak Backtrace:

malloc at nuttx/mm/umm_heap/umm_malloc.c:64
SyOSHeapAlloc atexternal/unqlite/unqlite/unqlite.c:26906
 (inlined by) MemOSAlloc at external/unqlite/unqlite/unqlite.c:27095
MemBackendAlloc at external/unqlite/unqlite/unqlite.c:27149
SyMemBackendAlloc at external/unqlite/unqlite/unqlite.c:27179
(discriminator 3) lhInstallCell at external/unqlite/unqlite/unqlite.c:49029
lhStoreCell at external/unqlite/unqlite/unqlite.c:50741
lhRecordInstall at external/unqlite/unqlite/unqlite.c:51065
 (inlined by) lh_record_insert at external/unqlite/unqlite/unqlite.c:51156
lh_record_insert at external/unqlite/unqlite/unqlite.c:51103
 (inlined by) lhash_kv_replace at external/unqlite/unqlite/unqlite.c:51184

Page cell table is alloced in lhInstallCell() when pPage->nCell < 1,
but not free the cell table when pPage->nCell == 0.

So when in the next call of lhInstallCell() and pPage->nCell == 0, cell
table is mallcoed again and old cell table not freed. Memory leak
happends.

Memory Leak Backtrace:
malloc at /data/project/n62/rel-4.0/nuttx/mm/umm_heap/umm_malloc.c:64
SyOSHeapAlloc at /data/project/n62/rel-4.0/external/unqlite/unqlite/unqlite.c:26906
 (inlined by) MemOSAlloc at /data/project/n62/rel-4.0/external/unqlite/unqlite/unqlite.c:27095
MemBackendAlloc at /data/project/n62/rel-4.0/external/unqlite/unqlite/unqlite.c:27149
SyMemBackendAlloc at /data/project/n62/rel-4.0/external/unqlite/unqlite/unqlite.c:27179 (discriminator 3)
lhInstallCell at /data/project/n62/rel-4.0/external/unqlite/unqlite/unqlite.c:49029
lhStoreCell at /data/project/n62/rel-4.0/external/unqlite/unqlite/unqlite.c:50741
lhRecordInstall at /data/project/n62/rel-4.0/external/unqlite/unqlite/unqlite.c:51065
 (inlined by) lh_record_insert at /data/project/n62/rel-4.0/external/unqlite/unqlite/unqlite.c:51156
lh_record_insert at /data/project/n62/rel-4.0/external/unqlite/unqlite/unqlite.c:51103
 (inlined by) lhash_kv_replace at /data/project/n62/rel-4.0/external/unqlite/unqlite/unqlite.c:51184

Signed-off-by: Bowen Wang <[email protected]>
@CV-Bowen
Copy link
Contributor Author

CV-Bowen commented Jan 4, 2024

@symisc I found a memory leak problem. Could take a look? Thanks.

@CV-Bowen CV-Bowen changed the title unqlite: fix the memmory leak about cell table unqlite: fix the memory leak about cell table Jan 4, 2024
@CV-Bowen
Copy link
Contributor Author

@symisc Hi, Could you take a look at this memory leak issue?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant