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.
pull/2/merge
chrox 12 years ago
parent b8131a1906
commit 060eeec1c1

@ -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);
}

@ -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);
}

Loading…
Cancel
Save