Skip to content

docs: explain memory collection in long-running processes - #1660

Open
bactiar291 wants to merge 1 commit into
python-openxml:masterfrom
bactiar291:docs/document-batch-memory-1646
Open

bactiar291 wants to merge 1 commit into
python-openxml:masterfrom
bactiar291:docs/document-batch-memory-1646

Conversation

@bactiar291

Copy link
Copy Markdown

Summary

Related to #1646 (the documentation request only).

Add a short user-guide section explaining that a document's part/package reference cycles are reclaimed by Python's cyclic garbage collector, independently of closing the input stream. Show a function-scoped processing example with collection after the function has returned, when its document objects are no longer retained.

The note also covers retained paragraph/table/run references, collection overhead, and the distinction between freeing objects and reducing process RSS. This is documentation only: no Document.close() API, weak-reference changes, global GC tuning, allocator calls, or changes to package behavior.

Validation

  • Upstream unit suite: 1609 passed, Python 3.12, pytest 8.4.1 (PYTEST_DISABLE_PLUGIN_AUTOLOAD=1 python -m pytest -p no:cacheprovider -q tests).
  • Executed the literal example extracted from the changed RST for one document and a batch of three documents. Both checks passed: saved files reopened with the expected text, and weak references to the processed document packages were cleared after the example completed.
  • Negative control: removing the example's gc.collect() made those checks fail with automatic GC disabled only inside the test harness; the public example does not disable GC.
  • Changed RST parsed without warnings with Docutils 0.21.2 and the project's |docx| substitution supplied. Full Sphinx build not run.
  • git diff --check passed.

Disclosure

Prepared and locally tested with AI assistance. No GUI-rendering or immediate-RSS-reduction claim is made.

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