Browse Source

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

Liang Ding 2 years ago
parent
commit
430bf34dfb
1 changed files with 5 additions and 0 deletions
  1. 5 0
      kernel/sql/queue.go

+ 5 - 0
kernel/sql/queue.go

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