mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-17 15:10:12 +01:00
🎨 内核垃圾回收
This commit is contained in:
parent
eea6c9468a
commit
74e7ecd5a5
8 changed files with 17 additions and 13 deletions
|
|
@ -25,7 +25,7 @@ import (
|
||||||
"os"
|
"os"
|
||||||
"path"
|
"path"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"runtime"
|
"runtime/debug"
|
||||||
"sort"
|
"sort"
|
||||||
"strings"
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
|
|
@ -517,7 +517,7 @@ func fullReindex() {
|
||||||
sql.EnableCache()
|
sql.EnableCache()
|
||||||
treenode.SaveBlockTree(true)
|
treenode.SaveBlockTree(true)
|
||||||
LoadFlashcards()
|
LoadFlashcards()
|
||||||
runtime.GC()
|
debug.FreeOSMemory()
|
||||||
go func() {
|
go func() {
|
||||||
time.Sleep(3 * time.Second)
|
time.Sleep(3 * time.Second)
|
||||||
util.PushClearMsg(msgId)
|
util.PushClearMsg(msgId)
|
||||||
|
|
|
||||||
|
|
@ -31,7 +31,7 @@ import (
|
||||||
"os"
|
"os"
|
||||||
"path"
|
"path"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"runtime"
|
"runtime/debug"
|
||||||
"sort"
|
"sort"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
@ -700,7 +700,7 @@ func ImportFromLocalPath(boxID, localPath string, toPath string) (err error) {
|
||||||
|
|
||||||
IncSync()
|
IncSync()
|
||||||
util.ReloadUI()
|
util.ReloadUI()
|
||||||
runtime.GC()
|
debug.FreeOSMemory()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -19,6 +19,7 @@ package model
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"runtime"
|
"runtime"
|
||||||
|
"runtime/debug"
|
||||||
"strings"
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
@ -125,7 +126,7 @@ func index(boxID string) {
|
||||||
end := time.Now()
|
end := time.Now()
|
||||||
elapsed := end.Sub(start).Seconds()
|
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)))
|
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
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,7 @@ import (
|
||||||
"os"
|
"os"
|
||||||
"path"
|
"path"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"runtime"
|
"runtime/debug"
|
||||||
"strings"
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
@ -149,7 +149,7 @@ func autoFixIndex() {
|
||||||
util.PushStatusBar(Conf.Language(58))
|
util.PushStatusBar(Conf.Language(58))
|
||||||
sql.WaitForWritingDatabase()
|
sql.WaitForWritingDatabase()
|
||||||
util.PushStatusBar(Conf.Language(185))
|
util.PushStatusBar(Conf.Language(185))
|
||||||
runtime.GC()
|
debug.FreeOSMemory()
|
||||||
}
|
}
|
||||||
|
|
||||||
func reindexTreeByUpdated(rootUpdatedMap, dbRootUpdatedMap map[string]string) {
|
func reindexTreeByUpdated(rootUpdatedMap, dbRootUpdatedMap map[string]string) {
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,7 @@
|
||||||
package sql
|
package sql
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"runtime"
|
"runtime/debug"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/88250/lute/ast"
|
"github.com/88250/lute/ast"
|
||||||
|
|
@ -45,7 +45,7 @@ func DisableCache() {
|
||||||
|
|
||||||
func ClearBlockCache() {
|
func ClearBlockCache() {
|
||||||
memCache.Clear()
|
memCache.Clear()
|
||||||
runtime.GC()
|
debug.FreeOSMemory()
|
||||||
}
|
}
|
||||||
|
|
||||||
func putBlockCache(block *Block) {
|
func putBlockCache(block *Block) {
|
||||||
|
|
|
||||||
|
|
@ -25,6 +25,7 @@ import (
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"regexp"
|
"regexp"
|
||||||
"runtime"
|
"runtime"
|
||||||
|
"runtime/debug"
|
||||||
"strings"
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
@ -1267,6 +1268,7 @@ func closeDatabase() (err error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
err = db.Close()
|
err = db.Close()
|
||||||
|
debug.FreeOSMemory()
|
||||||
runtime.GC() // 没有这句的话文件句柄不会释放,后面就无法删除文件
|
runtime.GC() // 没有这句的话文件句柄不会释放,后面就无法删除文件
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,7 @@ import (
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"path"
|
"path"
|
||||||
"runtime"
|
"runtime/debug"
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
|
@ -128,12 +128,12 @@ func FlushQueue() {
|
||||||
}
|
}
|
||||||
|
|
||||||
if 16 < i && 0 == i%128 {
|
if 16 < i && 0 == i%128 {
|
||||||
runtime.GC()
|
debug.FreeOSMemory()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if 128 < len(ops) {
|
if 128 < len(ops) {
|
||||||
runtime.GC()
|
debug.FreeOSMemory()
|
||||||
}
|
}
|
||||||
|
|
||||||
elapsed := time.Now().Sub(start).Milliseconds()
|
elapsed := time.Now().Sub(start).Milliseconds()
|
||||||
|
|
|
||||||
|
|
@ -21,6 +21,7 @@ import (
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"runtime"
|
"runtime"
|
||||||
|
"runtime/debug"
|
||||||
"strings"
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
@ -380,7 +381,7 @@ func InitBlockTree(force bool) {
|
||||||
waitGroup.Wait()
|
waitGroup.Wait()
|
||||||
p.Release()
|
p.Release()
|
||||||
|
|
||||||
runtime.GC()
|
debug.FreeOSMemory()
|
||||||
elapsed := time.Since(start).Seconds()
|
elapsed := time.Since(start).Seconds()
|
||||||
logging.LogInfof("read block tree [%s] to [%s], elapsed [%.2fs]", humanize.Bytes((size)), util.BlockTreePath, elapsed)
|
logging.LogInfof("read block tree [%s] to [%s], elapsed [%.2fs]", humanize.Bytes((size)), util.BlockTreePath, elapsed)
|
||||||
return
|
return
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue