File tree Expand file tree Collapse file tree 1 file changed +14
-13
lines changed Expand file tree Collapse file tree 1 file changed +14
-13
lines changed Original file line number Diff line number Diff line change @@ -151,6 +151,11 @@ int32_t HuffmanCheckTask::Run(DbSlice* db_slice) {
151151 for (unsigned char c : val) {
152152 hist_[c]++;
153153 }
154+
155+ if (val.size () > 1024 ) {
156+ traverses_count = kMaxTraverses ; // return early.
157+ string{}.swap (scratch_); // free memory.
158+ }
154159 }
155160 });
156161 traverses_count++;
@@ -721,19 +726,15 @@ void EngineShard::Heartbeat() {
721726 check_huffman = false ; // trigger only once.
722727
723728 // launch the task
724- HuffmanCheckTask* task = new HuffmanCheckTask ();
725- huffman_check_task_id_ = ProactorBase::me ()->AddOnIdleTask ([task] {
726- if (!shard_ || !namespaces) {
727- delete task;
728- return -1 ;
729- }
730-
731- DbSlice& db_slice = namespaces->GetDefaultNamespace ().GetDbSlice (shard_->shard_id ());
732- int32_t res = task->Run (&db_slice);
733- if (res == -1 )
734- delete task;
735- return res;
736- });
729+ huffman_check_task_id_ =
730+ ProactorBase::me ()->AddOnIdleTask ([task = HuffmanCheckTask{}]() mutable {
731+ if (!shard_ || !namespaces) {
732+ return -1 ;
733+ }
734+
735+ DbSlice& db_slice = namespaces->GetDefaultNamespace ().GetDbSlice (shard_->shard_id ());
736+ return task.Run (&db_slice);
737+ });
737738 }
738739 }
739740 }
You can’t perform that action at this time.
0 commit comments