* Change to set thread number
This patch is set thread number provided at hardware.
Signed-off-by: Changgyu Choi <changyu.choi@samsung.com>
* Add to trim memory
Signed-off-by: Changgyu Choi <changyu.choi@samsung.com>
* Change trim interval
Signed-off-by: Changgyu Choi <changyu.choi@samsung.com>
static const std::string SOCK_PATH = "/run/pkgmgr-info-server";
-Runner::Runner(int thread_num) : sid_(-1), thread_num_(thread_num) {
+Runner::Runner(int thread_num) : sid_(-1) {
+ if (thread_num > std::thread::hardware_concurrency())
+ thread_num_ = std::thread::hardware_concurrency();
+ else
+ thread_num_ = thread_num;
+
server_ = std::make_unique<pkgmgr_common::socket::ServerSocket>(SOCK_PATH);
thread_pool_ = std::make_unique<WorkerThread>(thread_num_);
sid_ = g_unix_fd_add(server_->GetFd(), G_IO_IN, OnReceiveRequest, this);
*/
#include "worker_thread.hh"
+#include <sqlite3.h>
+#include <malloc.h>
#include "pkgmgrinfo_debug.h"
#include "get_appinfo_request_handler.hh"
}
std::shared_ptr<PkgRequest> WorkerThread::PopQueue() {
+ static int cnt = 0;
+ if (++cnt % 50 == 0) { /* trim memory */
+ sqlite3_release_memory(-1);
+ malloc_trim(0);
+ }
+
auto req = queue_.front();
queue_.pop();
return req;