dompdf内存问题 [英] dompdf memory issues

查看:138
本文介绍了dompdf内存问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用DOMPDF从一个脚本生成大约500个报告.生成大约10-15个PDF后,它的内存不足.

I'm using DOMPDF to generate about 500 reports from one script. It's running out of memory after about 10-15 PDFs have been generated.

在调试中,每次加载字体看起来好像要加载8M,但这似乎应该由字体缓存代码来处理.

In debugging, it looks like it's loading 8M every time it gets to the font loading stuff, but this seems like something that should be handled with the font caching code.

这里有什么问题的想法吗?我想发布一个简单的代码段,但是大多数代码段被抽象为多个层,因此它不仅仅是一个简单的复制/粘贴.

Any ideas of what's going wrong here? I'd like to post a simple code snippet, but most of it is abstracted into multiple layers, so it's not just a simple copy/paste.

推荐答案

首先,如果这是出于远程商业目的,则只需王子XML .它比任何其他HTML到PDF解决方案都要好得多,而且速度也更快(我已经研究了所有的解决方案).节省的开发人员时间将很快收回成本.

First if this is for anything remotely commercial just get Prince XML. It's substantially better and faster than any other HTML to PDF solution (and I've looked at them all). The cost will quickly be recouped in saved developer time.

第二,最快的解决方案可能是在单独的过程中打印每个报告,以解决任何内存泄漏问题.如果这是从命令行运行的,则外部循环应类似于Shell脚本,它将为每个报告启动一个过程.如果它是从Web分支运行的,那么,如果您使用的操作系统可以执行此操作,那么每个脚本都会有一个过程.

Second, the quickest solution is probably to print each report in a separate process to solve any memory leak problems. If this is running from the command line have the outer loop be something like a shell script that will start a process for each report. If it's run from the Web fork a process for each script if you're on an OS that can do that.

看看使用PHP将HTML + CSS转换为PDF吗?.

这篇关于dompdf内存问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆