1
0
Fork 0
mirror of https://github.com/mozilla/pdf.js.git synced 2025-04-26 10:08:06 +02:00

Ensure that the Cmd/Name/Ref caches are cleared when running other cleanup code

The purpose of these caches is to reduce peak memory usage, by only ever having *a single* instance of a particular object.
However, as-is these caches are never cleared and they will thus remain until the worker is destroyed. This could very well have a negative effect on total memory usage, particularly for large/long documents, hence it seems to make sense to clear out these caches together with various other ones.
This commit is contained in:
Jonas Jenwald 2019-05-26 14:20:31 +02:00
parent 9ab1d9f596
commit 5e045bcdba
2 changed files with 27 additions and 7 deletions

View file

@ -20,8 +20,8 @@ import {
warn
} from '../shared/util';
import {
Dict, isCmd, isDict, isName, isRef, isRefsEqual, isStream, Ref, RefSet,
RefSetCache
clearPrimitiveCaches, Dict, isCmd, isDict, isName, isRef, isRefsEqual,
isStream, Ref, RefSet, RefSetCache
} from './primitives';
import { Lexer, Parser } from './parser';
import {
@ -662,6 +662,7 @@ class Catalog {
}
cleanup() {
clearPrimitiveCaches();
this.pageKidsCountCache.clear();
const promises = [];