comparison OrthancServer/Sources/ServerContext.cpp @ 5181:65b05b44ae4c

properly finalizing the housekeeper thread that periodically calls malloc_trim()
author Sebastien Jodogne <s.jodogne@gmail.com>
date Sat, 25 Mar 2023 11:27:37 +0100
parents 6d8647122ef3
children cddf28cfcd8d
comparison
equal deleted inserted replaced
5180:d2626a062809 5181:65b05b44ae4c
434 jobsEngine_.SetThreadSleep(unitTesting ? 20 : 200); 434 jobsEngine_.SetThreadSleep(unitTesting ? 20 : 200);
435 435
436 listeners_.push_back(ServerListener(luaListener_, "Lua")); 436 listeners_.push_back(ServerListener(luaListener_, "Lua"));
437 changeThread_ = boost::thread(ChangeThread, this, (unitTesting ? 20 : 100)); 437 changeThread_ = boost::thread(ChangeThread, this, (unitTesting ? 20 : 100));
438 #if HAVE_MALLOC_TRIM == 1 438 #if HAVE_MALLOC_TRIM == 1
439 housekeeperThread_ = boost::thread(HousekeeperThread, this, 100); 439 housekeeperThread_ = boost::thread(HousekeeperThread, this, 1000);
440 #else 440 #else
441 LOG(INFO) << "Your platform does not support malloc_trim(), not starting the housekeeper thread"; 441 LOG(INFO) << "Your platform does not support malloc_trim(), not starting the housekeeper thread";
442 #endif 442 #endif
443 dynamic_cast<DcmtkTranscoder&>(*dcmtkTranscoder_).SetLossyQuality(lossyQuality); 443 dynamic_cast<DcmtkTranscoder&>(*dcmtkTranscoder_).SetLossyQuality(lossyQuality);
444 } 444 }
478 } 478 }
479 479
480 if (saveJobsThread_.joinable()) 480 if (saveJobsThread_.joinable())
481 { 481 {
482 saveJobsThread_.join(); 482 saveJobsThread_.join();
483 }
484
485 if (housekeeperThread_.joinable())
486 {
487 housekeeperThread_.join();
483 } 488 }
484 489
485 jobsEngine_.GetRegistry().ResetObserver(); 490 jobsEngine_.GetRegistry().ResetObserver();
486 491
487 if (isJobsEngineUnserialized_) 492 if (isJobsEngineUnserialized_)