🎨 内核垃圾回收

This commit is contained in:
Liang Ding 2023-02-04 14:58:35 +08:00
parent eea6c9468a
commit 74e7ecd5a5
No known key found for this signature in database
GPG key ID: 136F30F901A2231D
8 changed files with 17 additions and 13 deletions

View file

@ -25,7 +25,7 @@ import (
"os"
"path"
"path/filepath"
"runtime"
"runtime/debug"
"sort"
"strings"
"sync"
@ -517,7 +517,7 @@ func fullReindex() {
sql.EnableCache()
treenode.SaveBlockTree(true)
LoadFlashcards()
runtime.GC()
debug.FreeOSMemory()
go func() {
time.Sleep(3 * time.Second)
util.PushClearMsg(msgId)

View file

@ -31,7 +31,7 @@ import (
"os"
"path"
"path/filepath"
"runtime"
"runtime/debug"
"sort"
"strconv"
"strings"
@ -700,7 +700,7 @@ func ImportFromLocalPath(boxID, localPath string, toPath string) (err error) {
IncSync()
util.ReloadUI()
runtime.GC()
debug.FreeOSMemory()
return
}

View file

@ -19,6 +19,7 @@ package model
import (
"fmt"
"runtime"
"runtime/debug"
"strings"
"sync"
"time"
@ -125,7 +126,7 @@ func index(boxID string) {
end := time.Now()
elapsed := end.Sub(start).Seconds()
logging.LogInfof("rebuilt database for notebook [%s] in [%.2fs], tree [count=%d, size=%s]", box.ID, elapsed, treeCount, humanize.Bytes(uint64(treeSize)))
runtime.GC()
debug.FreeOSMemory()
return
}

View file

@ -21,7 +21,7 @@ import (
"os"
"path"
"path/filepath"
"runtime"
"runtime/debug"
"strings"
"sync"
"time"
@ -149,7 +149,7 @@ func autoFixIndex() {
util.PushStatusBar(Conf.Language(58))
sql.WaitForWritingDatabase()
util.PushStatusBar(Conf.Language(185))
runtime.GC()
debug.FreeOSMemory()
}
func reindexTreeByUpdated(rootUpdatedMap, dbRootUpdatedMap map[string]string) {