diff --git a/cpp/conf/server_config.template b/cpp/conf/server_config.template index 215ca45027..2942ffa179 100644 --- a/cpp/conf/server_config.template +++ b/cpp/conf/server_config.template @@ -34,7 +34,7 @@ license_config: # license configure cache_config: # cache configure cpu_cache_capacity: 16 # how many memory are used as cache, unit: GB, range: 0 ~ less than total memory - cache_free_percent: 0.85 # how much memory should be free when cache is full, range: greater than zero ~ 1.0 + cache_free_percent: 0.85 # old data will be erased from cache when cache is full, this value specify how much memory should be kept, range: greater than zero ~ 1.0 insert_cache_immediately: false # insert data will be load into cache immediately for hot query engine_config: diff --git a/cpp/src/cache/Cache.cpp b/cpp/src/cache/Cache.cpp index 0cc804ac5f..a1f2520302 100644 --- a/cpp/src/cache/Cache.cpp +++ b/cpp/src/cache/Cache.cpp @@ -163,6 +163,9 @@ void Cache::free_memory() { int64_t threshhold = capacity_ * freemem_percent_; int64_t delta_size = usage_ - threshhold; + if(delta_size <= 0) { + delta_size = 1;//ensure at least one item erased + } std::set key_array; int64_t released_size = 0;