Skip to content

An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作

:art: Limit memory usage of PDF parsing https://github.com/siyuan-note/siyuan/pull/9051

Daniel06f6534402e6
diff --git a/kernel/model/asset_content.go b/kernel/model/asset_content.go
index cdb8fd09ab..b3a8a98d93 100644
--- a/kernel/model/asset_content.go
+++ b/kernel/model/asset_content.go
@@ -774,6 +774,10 @@ func (parser *PdfAssetParser) Parse(absPath string) (ret *AssetParseResult) {
// initialize go-pdfium with number of available cores
// we fire up the complete worker pool for maximum performance
cores := runtime.NumCPU()
+ if 4 < cores {
+ cores = 4 // Limit memory usage
+ }
+
pool, err := webassembly.Init(webassembly.Config{
MinIdle: cores,
MaxIdle: cores,
@@ -853,7 +857,7 @@ func (parser *PdfAssetParser) Parse(absPath string) (ret *AssetParseResult) {
close(results)
if 128 < pc.PageCount {
- logging.LogInfof("convert [%s] PDF with [%d[ pages using [%d] workers took [%s]", absPath, pc.PageCount, cores, time.Since(now))
+ logging.LogInfof("convert [%s] PDF with [%d] pages using [%d] workers took [%s]", absPath, pc.PageCount, cores, time.Since(now))
}
// loop through ordered PDF text pages and join content for asset parse DB result