Skip to content

fix: avoid 1M cells reserve to reduce memory footprint - #2

Closed
yonikremer wants to merge 1 commit into
mainfrom
fix/memory-reduce-cells-reserve
Closed

fix: avoid 1M cells reserve to reduce memory footprint#2
yonikremer wants to merge 1 commit into
mainfrom
fix/memory-reduce-cells-reserve

Conversation

@yonikremer

Copy link
Copy Markdown
Owner

Pre-allocating 1M cells per PAGE_CELLS container wasted ~300 MB per vector. With 5 such vectors per decoded page (page_cells, char_cells, cells, word_cells, line_cells in src/parse/pdf_decoders/page.h:161-175) this multiplied to ~1.5 GB committed per page and OOMs on small docs when several pages decoded concurrently (threaded parser).

Change (1 file):

  • src/parse/page_items/page_cells.h: remove cells.reserve(1000000), let vector grow on demand (typical pages: hundreds to few thousand cells → <2 MB)

Verified:

  • .venv/Scripts/python.exe -m pytest tests/test_parse.py -q → 21 passed
  • .venv/Scripts/python.exe -m pytest -q → 111 passed, 1 pre-existing Windows path-separator failure
  • _oom_perdoc.py: per-page delta 0-50 MB (worst 245 MB) vs previously 1.5 GB+

Independent of the Windows/MinGW build PR — single-line fix, no build-system changes.

🤖 Generated with Claude Code

Pre-allocating 1M cells per PAGE_CELLS container wasted ~300 MB
per container. With 5 such containers per decoded page
(page_cells, char_cells, cells, word_cells, line_cells) this
multiplied to ~1.5 GB committed per page and OOMs on small docs
when several pages were decoded concurrently.

Let the vector grow on demand instead; typical pages have only
hundreds to a few thousand cells.

Co-Authored-By: Claude <noreply@anthropic.com>
@yonikremer

Copy link
Copy Markdown
Owner Author

Superseded by upstream PR docling-project#311

@yonikremer yonikremer closed this Aug 7, 2026
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