PDFLib to PHP hogging resources, not file cleanup

I just inherited a PHP project that generates large PDF files and usually throttles through several thousand pages and several concerts of server memory. The project used PDFLib to generate these files in memory.

I was tasked with fixing this, so the first thing I did was send the PDFLib file to a file instead of creating it in memory. The problem is that it still seems to be creating PDF memory. And most of the memory never returns to the OS. In the end, all things choke and die.

When I ask the program to create only fragments of large PDF files, it seems that the data is not completely cleared to the file on end_document (). I get no errors, but the PDF is not readable and opening it in a hex editor makes it obvious that the stream is incomplete.

I hope someone has similar difficulties.

+3
source share
2 answers

Solved! You need to call PDF_delete_textflow () for each text stream, since they are provided with a document area and do not disappear until the document is closed, which never happened, since all available memory was exhausted to this point.

+2
source

, , . "end_page_ext" .

, PDF-, "close_pdi_page" "close_pdi_document", .

+1

Source: https://habr.com/ru/post/1709827/


All Articles