简体   繁体   English

消耗内存的TCPDF并没有释放内存

[英]TCPDF consuming the Memory & It is not freeing up memory

I am using TCPDF library to generate report on one of my application. 我正在使用TCPDF库生成我的一个应用程序的报告。 When ever i generate PDF using TCPDF, chunk of memory get allocated like 256MB & after generating the PDF, that allocated memory is not getting free. 当我使用TCPDF生成PDF时,内存块被分配为256MB并且在生成PDF之后,分配的内存不会被释放。

This is blocking around 2GB memory. 这阻止了大约2GB的内存。 So the final solution which i have is change the TCPDF lib with other lib. 所以我的最终解决方案是用其他lib更改TCPDF lib。

Can anybody knows why TCPDF allocates the memory or is there any way to flush the memory after the pdf generation? 任何人都可以知道为什么TCPDF会分配内存,还是有任何方法在pdf生成后刷新内存?

If you have PHP5 running on your server: does your TCPDF object have a __deconstruct() method? 如果您的服务器上运行了PHP5:您的TCPDF对象是否有__deconstruct()方法?

If you have PHP4 running on your server: try unset($pdfobject) . 如果您的服务器上运行PHP4:尝试unset($pdfobject)

Run these methods once you're done creating/writing/printing your PDF. 完成创建/编写/打印PDF后,运行这些方法。

Are you cleaning your output buffer in your View? 您是否在View中清理输出缓冲区? I am also using TCPDF in some of my Cake projects, but never had this problem. 我也在我的一些Cake项目中使用TCPDF,但从未遇到过这个问题。 Your view should have somthing like this: 你的观点应该是这样的:

<?php
// Start output buffering
ob_start();

// Your TCPDF code here

// Clean the output buffer
ob_end_clean();

Works just fine for me, memory is freed right after generation. 对我来说工作得很好,记忆一代又一代地释放。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM