mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-02-28 05:32:52 +00:00
🎨 内核垃圾回收
This commit is contained in:
@@ -17,7 +17,7 @@
|
||||
package sql
|
||||
|
||||
import (
|
||||
"runtime"
|
||||
"runtime/debug"
|
||||
"time"
|
||||
|
||||
"github.com/88250/lute/ast"
|
||||
@@ -45,7 +45,7 @@ func DisableCache() {
|
||||
|
||||
func ClearBlockCache() {
|
||||
memCache.Clear()
|
||||
runtime.GC()
|
||||
debug.FreeOSMemory()
|
||||
}
|
||||
|
||||
func putBlockCache(block *Block) {
|
||||
|
||||
@@ -25,6 +25,7 @@ import (
|
||||
"path/filepath"
|
||||
"regexp"
|
||||
"runtime"
|
||||
"runtime/debug"
|
||||
"strings"
|
||||
"sync"
|
||||
"time"
|
||||
@@ -1267,6 +1268,7 @@ func closeDatabase() (err error) {
|
||||
}
|
||||
|
||||
err = db.Close()
|
||||
debug.FreeOSMemory()
|
||||
runtime.GC() // 没有这句的话文件句柄不会释放,后面就无法删除文件
|
||||
return
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@ import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"path"
|
||||
"runtime"
|
||||
"runtime/debug"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
@@ -128,12 +128,12 @@ func FlushQueue() {
|
||||
}
|
||||
|
||||
if 16 < i && 0 == i%128 {
|
||||
runtime.GC()
|
||||
debug.FreeOSMemory()
|
||||
}
|
||||
}
|
||||
|
||||
if 128 < len(ops) {
|
||||
runtime.GC()
|
||||
debug.FreeOSMemory()
|
||||
}
|
||||
|
||||
elapsed := time.Now().Sub(start).Milliseconds()
|
||||
|
||||
Reference in New Issue
Block a user