mirror of
https://github.com/koreader/koreader.git
synced 2025-08-10 00:52:38 +00:00
bugfix: reclaim thread stack explicitly by using detached threads
Otherwise the VmData size will keep increasing in multi-threads mode. Although the increasing VmData size doesn't mean there is enormous memory leak, it does show that the thread stack is not handled properly when threads exit.
This commit is contained in:
5
djvu.c
5
djvu.c
@@ -531,7 +531,10 @@ static int reflowPage(lua_State *L) {
|
||||
kctx->src = src;
|
||||
if (kctx->precache) {
|
||||
pthread_t rf_thread;
|
||||
pthread_create(&rf_thread, NULL, k2pdfopt_reflow_bmp, (void*) kctx);
|
||||
pthread_attr_t attr;
|
||||
pthread_attr_init(&attr);
|
||||
pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
|
||||
pthread_create(&rf_thread, &attr, k2pdfopt_reflow_bmp, (void*) kctx);
|
||||
} else {
|
||||
k2pdfopt_reflow_bmp(kctx);
|
||||
}
|
||||
|
||||
5
pdf.c
5
pdf.c
@@ -615,7 +615,10 @@ static int reflowPage(lua_State *L) {
|
||||
kctx->src = src;
|
||||
if (kctx->precache) {
|
||||
pthread_t rf_thread;
|
||||
pthread_create( &rf_thread, NULL, k2pdfopt_reflow_bmp, (void*) kctx);
|
||||
pthread_attr_t attr;
|
||||
pthread_attr_init(&attr);
|
||||
pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
|
||||
pthread_create( &rf_thread, &attr, k2pdfopt_reflow_bmp, (void*) kctx);
|
||||
} else {
|
||||
k2pdfopt_reflow_bmp(kctx);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user