浏览代码

:art: 改进内核任务调度机制提升稳定性 https://github.com/siyuan-note/siyuan/issues/7113

Liang Ding 2 年之前
父节点
当前提交
430bf34dfb
共有 1 个文件被更改,包括 5 次插入0 次删除
  1. 5 0
      kernel/sql/queue.go

+ 5 - 0
kernel/sql/queue.go

@@ -21,6 +21,7 @@ import (
 	"errors"
 	"fmt"
 	"path"
+	"runtime"
 	"sync"
 	"time"
 
@@ -125,6 +126,10 @@ func FlushQueue() {
 			logging.LogErrorf("commit tx failed: %s", err)
 			return
 		}
+
+		if 16 < i && 0 == i%256 {
+			runtime.GC()
+		}
 	}
 
 	elapsed := time.Now().Sub(start).Milliseconds()