Skip to content

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

Merged
PeterStaar-IBM merged 2 commits into
docling-project:mainfrom
yonikremer:fix/memory-reduce-cells-reserve
Aug 8, 2026
Merged

fix: avoid 1M cells reserve to reduce memory footprint#311
PeterStaar-IBM merged 2 commits into
docling-project:mainfrom
yonikremer:fix/memory-reduce-cells-reserve

Conversation

@yonikremer

Copy link
Copy Markdown
Contributor

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.

🤖 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>
@github-actions

github-actions Bot commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

DCO Check Passed

Thanks @yonikremer, all your commits are properly signed off. 🎉

@mergify

mergify Bot commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

Merge Protections

🟢 Merge protection satisfied — ready to merge.

Show 1 satisfied protection

🟢 Enforce conventional commit

Make sure that we follow https://www.conventionalcommits.org/en/v1.0.0/

  • title ~= ^(fix|feat|docs|style|refactor|perf|test|build|ci|chore|revert)(?:\(.+\))?(!)?:

I, yoni kremer <yoni.kremer@gmail.com>, hereby add my Signed-off-by to this commit: 8922d06

Signed-off-by: yoni kremer <yoni.kremer@gmail.com>

@PeterStaar-IBM PeterStaar-IBM left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm!

@PeterStaar-IBM
PeterStaar-IBM merged commit e892b85 into docling-project:main Aug 8, 2026
36 checks passed
@yonikremer
yonikremer deleted the fix/memory-reduce-cells-reserve branch August 8, 2026 06: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.

2 participants