mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-16 22:50:13 +01:00
🎨 Limit memory usage of PDF parsing https://github.com/siyuan-note/siyuan/pull/9051
This commit is contained in:
parent
0ec9a28763
commit
06f6534402
1 changed files with 5 additions and 1 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue