Skip to content

🐝 Reduce PDF viewer memory retention across indexing, search, and minimap rendering - #225

Merged
JFWooten4 merged 5 commits into
mainfrom
the-headless-horse
Nov 17, 2026
Merged

JFWooten4 merged 5 commits into
mainfrom
the-headless-horse

Conversation

@kefania-pony

@kefania-pony kefania-pony Bot commented Nov 7, 2026

Copy link
Copy Markdown
Contributor

Reduce avoidable memory retention when many PDF documents are open by cleaning up per-page resources used by background indexing, footnote lookup, search, and minimap preparation. This addresses auxiliary work outside the viewer's visible-page render window without limiting which pages can be searched.

  • The OCR-aware two-pass footnote index developed in 🐞 Recover scanned-PDF footnotes and speed up footnote navigation #169 now calls page.cleanup() after each page in both passes, including failure paths. Printed-page-label indexing and search-text extraction also use the documented PDF.js page cleanup API.
  • Footnote jumps stop retaining a page-number cache of full drawing operator lists, which may contain decoded image data. They process one page at a time, keep only extracted text and separator-rule geometry, and clean up the page after reading it.
  • The extracted-text cache introduced in 🖌️ Add persistent header PDF search #4 is now least-recently-used with an estimated 25 MiB budget per viewer. Older entries are evicted and oversized pages are not cached; both remain searchable through re-extraction.
  • The composed and cached minimap strip introduced in ⚡ Persist and sharpen document minimaps #81 is preserved, while temporary per-page canvases are cleared after composition or a failed/stale render. Thumbnail workers now settle before those canvases are released.
  • New regression tests exercise cache eviction, oversized pages, separator-only footnote data, cleanup on extraction errors, and thumbnail release. npm test includes the new document-memory suite.

The 25 MiB budget estimates text-item storage, not total browser RAM or a strict heap ceiling. The originating conversation reported approximately 40 GB of Brave memory use but omits intermediate tool activity and contains no verified post-change measurement; an actual memory reduction has not yet been quantified.

Source links

Online · Local · Desktop

JFWooten4 and others added 5 commits November 7, 2026 17:02
Co-authored-by: Codex <noreply@openai.com>
Co-authored-by: Codex <noreply@openai.com>
Resolve conflicts between PR #225's memory-retention improvements and the latest main branch.

Preserve current viewer navigation, outline, text-link, and minimap behavior while integrating cleanup, cache eviction, and related tests. Register document-memory.test.mjs in the feature-suite runner.

Co-authored-by: ChatGPT 6 <noreply@openai.com>
Update the scanned-hearing page mock to implement PDF.js cleanup and verify it runs when the lookup returns early.
Provide the exported separator-rule helper to the scanned-petition lookup sandbox so it exercises current footnote parsing.

Co-authored-by: ChatGPT 6 <noreply@openai.com>
@JFWooten4
JFWooten4 merged commit 7c28b67 into main Nov 17, 2026
14 checks passed
@JFWooten4
JFWooten4 deleted the the-headless-horse branch November 17, 2026 20:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant