Any need or way to explicitly release resources from loadPage #975
-
First of all, thanks to all involved in maintaining this very useful library! Second, please excuse a naive question but I am paranoid given some performance/memory challenges I am dealing with. (I am processing large format PDF pages in documents with a large page count ( 600+)) If I call loadPage in a for loop assigning to a single variable, is there any need to make an explicit call to release page resources at the end of the loop? Or will this happen automatically as the reference to the old object is overwritten each time around? document = fitz.open(local_document_filename) Thanks for reading |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 5 replies
-
No, this happens automatically when the name You are aware that your loop has a more elegant variant: for page in document:
# process 'page'
# or from back to front:
for page in reversed(document):
# process 'page' Slice-like variants also exist. for page in document.pages(100, 13, -1):
# ... |
Beta Was this translation helpful? Give feedback.
No, this happens automatically when the name
page
is re-assigned, so no worries.Except for the last page of course ... which will be freed by either end of script or you may assign it to None or delete it.
You are aware that your loop has a more elegant variant:
Slice-like variants also exist.