I also suffered from memory leak problems. After some research and code tuning, my problems were resolved. I basically worked correctly, using both the destroy () function .
In some cases, I could use c to open and read files, as in the example below:
with Image(filename = pdf_file, resolution = 300) as pdf:
In this case, using with, the memory and tmp files are properly managed.
In another case, I had to use the destroy () function, preferably inside the try / finally block, as shown below:
try: for img in pdfImg.sequence:
The second case, this is an example where I can not use with , because I had to iterate over the pages in sequence , so I already had the file open and I iterate your pages.
This combination of solution solved my problems with memory leaks.
source share