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:
chrox committed 2012-11-26 22:17:02 +08:00
1 parent b8131a1906
commit 060eeec1c1
2 files changed
+8 -2

No files matched your search

+4 -1
View File
@@ -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);
}
+4 -1
View File
@@ -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);
}