@@ -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)
@@ -31,7 +31,7 @@ import (
"strconv"
@@ -700,7 +700,7 @@ func ImportFromLocalPath(boxID, localPath string, toPath string) (err error) {
IncSync()
util.ReloadUI()
return
}
@@ -19,6 +19,7 @@ package model
import (
"fmt"
"runtime"
"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)))
@@ -21,7 +21,7 @@ import (
@@ -149,7 +149,7 @@ func autoFixIndex() {
util.PushStatusBar(Conf.Language(58))
sql.WaitForWritingDatabase()
util.PushStatusBar(Conf.Language(185))
func reindexTreeByUpdated(rootUpdatedMap, dbRootUpdatedMap map[string]string) {
@@ -17,7 +17,7 @@
package sql
"github.com/88250/lute/ast"
@@ -45,7 +45,7 @@ func DisableCache() {
func ClearBlockCache() {
memCache.Clear()
func putBlockCache(block *Block) {
@@ -25,6 +25,7 @@ import (
"regexp"
@@ -1267,6 +1268,7 @@ func closeDatabase() (err error) {
err = db.Close()
runtime.GC() // 没有这句的话文件句柄不会释放,后面就无法删除文件
"errors"
@@ -128,12 +128,12 @@ func FlushQueue() {
if 16 < i && 0 == i%128 {
if 128 < len(ops) {
elapsed := time.Now().Sub(start).Milliseconds()
@@ -21,6 +21,7 @@ import (
@@ -380,7 +381,7 @@ func InitBlockTree(force bool) {
waitGroup.Wait()
p.Release()
elapsed := time.Since(start).Seconds()
logging.LogInfof("read block tree [%s] to [%s], elapsed [%.2fs]", humanize.Bytes((size)), util.BlockTreePath, elapsed)