Skip to content
This repository has been archived by the owner on Jun 10, 2022. It is now read-only.

Commit

Permalink
add malloc trim
Browse files Browse the repository at this point in the history
  • Loading branch information
nmred committed Jun 2, 2017
1 parent 73ba9ed commit 539ab05
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 4 deletions.
13 changes: 9 additions & 4 deletions conf/system.ini
Original file line number Diff line number Diff line change
@@ -1,16 +1,21 @@
[system]
appid=0
macid=0
daemon=yes
daemon=no
pidFile=./aidp.pid
; malloc trim 128kb
mallocTrimPad=131072
; malloc trim interval
; 5s
mallocTrimInterval=1000

[logging]
logsDir=logs/
; 日志分卷大小
logRollSize=52428800
; 1: LOG_TRACE 2: LOG_DEBUG 3: LOG_INFO
logLevel=3
isAsync=yes
isAsync=no

[adserver]
; 是否启动 mc server
Expand All @@ -30,7 +35,7 @@ serverName=mc-server
host=0.0.0.0
port=10053
timeout=3
threadNum=4
threadNum=1
serverName=adinf-adserver
accessLogDir=logs/
accesslogRollSize=52428800
Expand All @@ -48,7 +53,7 @@ serverName=head-server
; 支持同时消费多个 topic, 多个用逗号分隔
topicNameOut=test
groupIdOut=test_group_id
brokerListOut=10.77.96.136:9192,10.77.96.137:9192
brokerListOut=127.0.0.1:9192
kafkaDebugOut=none
statIntervalOut=60000

Expand Down
2 changes: 2 additions & 0 deletions src/AdbaseConfig.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ typedef struct adbaseConfig {
std::string pidFile;
int appid;
int macid;
int mallocTrimPad;
int mallocTrimInterval;

// logging config
std::string logsDir;
Expand Down
2 changes: 2 additions & 0 deletions src/App.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,8 @@ void App::setAims(std::shared_ptr<Aims>& aims) {
//{{{ void App::loadConfig()

void App::loadConfig(adbase::IniConfig& config) {
_configure->mallocTrimInterval = config.getOptionUint32("system", "mallocTrimInterval");
_configure->mallocTrimPad = config.getOptionUint32("system", "mallocTrimPad");
_configure->luaDebug = config.getOptionBool("lua", "debug");
_configure->luaScriptPath = config.getOption("lua", "scriptPath");
_configure->consumerScriptName = config.getOption("consumer", "scriptName");
Expand Down
8 changes: 8 additions & 0 deletions src/Timer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ void Timer::init() {
//ADD_AFTER_TIMER(1 * 1000, one);
ADD_EVERY_TIMER(_configure->intervalClearStorage, clearStorage);
ADD_EVERY_TIMER(10000, checkMessageQueue);
ADD_EVERY_TIMER(_configure->mallocTrimInterval, mallocTrim);
}

// }}}
Expand All @@ -71,3 +72,10 @@ void Timer::checkMessageQueue(void*) {
}

// }}}
// {{{ void Timer::mallocTrim()

void Timer::mallocTrim(void*) {
adbase::mallocTrim(_configure->mallocTrimPad);
}

// }}}
1 change: 1 addition & 0 deletions src/Timer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ class Timer {
adbase::Timer* getTimer();
void clearStorage(void* args);
void checkMessageQueue(void* args);
void mallocTrim(void* args);

private:
/// 传输上下文指针
Expand Down

0 comments on commit 539ab05

Please sign in to comment.