Issues

ZF-8462: Allowed memory size exhausted when loading small pdf

Description

I am always getting memory exhausted error when loading small pdf (see attached file). This is on Windows 7 64-Bit with IIS. I tried setting memory_limit to 200M. But that did not help.

My Code:

    $pdf = Zend_Pdf::load($this->_config->paths->application.'/models/resources/mietvertrag2.pdf'); 
$pdf->save($this->_config->paths->files.'/'.createFilename(), true);

Fatal error: Allowed memory size of 12582912 bytes exhausted (tried to allocate 98304 bytes) in G:\Inetpub\wwwroot\php\Zend\1-9-5\library\Zend\Pdf\Resource\Font\Simple\Standard\Symbol.php on line 285 Call Stack: 0.0959 809432 1. {main}() G:\Inetpub\wwwroot\wirecard\index.php:0 0.2931 7057640 2. Zend_Application->run() G:\Inetpub\wwwroot\wirecard\index.php:65 0.2931 7057640 3. Zend_Application_Bootstrap_Bootstrap->run() G:\Inetpub\wwwroot\php\Zend\1-9-5\library\Zend\Application.php:358 0.2936 7057816 4. Zend_Controller_Front->dispatch() G:\Inetpub\wwwroot\php\Zend\1-9-5\library\Zend\Application\Bootstrap\Bootstrap.php:77 0.3117 7710112 5. Zend_Controller_Dispatcher_Standard->dispatch() G:\Inetpub\wwwroot\php\Zend\1-9-5\library\Zend\Controller\Front.php:946 0.3388 8002832 6. Zend_Controller_Action->dispatch() G:\Inetpub\wwwroot\php\Zend\1-9-5\library\Zend\Controller\Dispatcher\Standard.php:289 0.3391 8006048 7. PosController->newAction() G:\Inetpub\wwwroot\php\Zend\1-9-5\library\Zend\Controller\Action.php:513 0.3433 8293464 8. Wirecard_Model_Pos->makePdf() G:\Inetpub\application\wirecard\controllers\PosController.php:9 0.3433 8293696 9. Zend_Loader_Autoloader::autoload() G:\Inetpub\wwwroot\php\Zend\1-9-5\library\Zend\Loader\Autoloader.php:0 0.3437 8294320 10. call_user_func() G:\Inetpub\wwwroot\php\Zend\1-9-5\library\Zend\Loader\Autoloader.php:130 0.3437 8294336 11. Zend_Loader_Autoloader->_autoload() G:\Inetpub\wwwroot\php\Zend\1-9-5\library\Zend\Loader\Autoloader.php:0 0.3438 8294368 12. call_user_func() G:\Inetpub\wwwroot\php\Zend\1-9-5\library\Zend\Loader\Autoloader.php:474 0.3438 8294384 13. Zend_Loader::loadClass() G:\Inetpub\wwwroot\php\Zend\1-9-5\library\Zend\Loader\Autoloader.php:0 0.3469 8641056 14. include('G:\Inetpub\wwwroot\php\Zend\1-9-5\library\Zend\Pdf.php') G:\Inetpub\wwwroot\php\Zend\1-9-5\library\Zend\Loader.php:83 0.4071 10906432 15. require_once('G:\Inetpub\wwwroot\php\Zend\1-9-5\library\Zend\Pdf\Font.php') G:\Inetpub\wwwroot\php\Zend\1-9-5\library\Zend\Pdf.php:29

Comments

Can you show me how you tried to increase your memory limit? Please also check the output of ini_get or phpinfo() if your changes are working for the vhost/config where your script is running under.

I think the Zend_Pdf will not try to change any memory limit that has to do by the developer itself.

I tried directly in php.ini memory_limt=200M

and in config.ini phpSettings.memory_limit=128M

I tested your example and it worked perfectly for my environment.

can you verify that your configuration value has been applied? var_dump(ini_get('memory_limit'));

btw. memory_limt=200M <<< there is a missing i memory_limit=200M is better.

I must correct myself. Works now with the attached pdf but error still occurs with another small pdf which I cannot attach because of confidential information. Must be some pdf related reason. I will try to find out and post in case a examplary pdf.

Yes I verified with ini_get beforde the pdf function that the memory is correctly set

Some more information regarding the error

  • Memory_Limit ist set to 128M (verified with ini_get)
  • Error is Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 118753281 bytes) in

and pdf has 600KB

I resolve this issue. If you have a reproducable example with an example pdf please reopen this issue.

  • pdf is attached.
  • memory_limit ist 128M

Exception is [04-Dec-2009 11:25:10] PHP Notice: Indirect modification of overloaded property Zend_Pdf_Element_Object_Stream::$value has no effect in G:\Inetpub\wwwroot\php\Zend\1-9-5\library\Zend\Pdf\Parser.php on line 267 [04-Dec-2009 11:25:10] PHP Stack trace: [04-Dec-2009 11:25:10] PHP 1. {main}() G:\Inetpub\wwwroot\w\index.php:0 [04-Dec-2009 11:25:10] PHP 2. Zend_Application->run() G:\Inetpub\wwwroot\w\index.php:65 [04-Dec-2009 11:25:10] PHP 3. Zend_Application_Bootstrap_Bootstrap->run() G:\Inetpub\wwwroot\php\Zend\1-9-5\library\Zend\Application.php:358 [04-Dec-2009 11:25:10] PHP 4. Zend_Controller_Front->dispatch() G:\Inetpub\wwwroot\php\Zend\1-9-5\library\Zend\Application\Bootstrap\Bootstrap.php:77 [04-Dec-2009 11:25:10] PHP 5. Zend_Controller_Dispatcher_Standard->dispatch() G:\Inetpub\wwwroot\php\Zend\1-9-5\library\Zend\Controller\Front.php:946 [04-Dec-2009 11:25:10] PHP 6. Zend_Controller_Action->dispatch() G:\Inetpub\wwwroot\php\Zend\1-9-5\library\Zend\Controller\Dispatcher\Standard.php:289 [04-Dec-2009 11:25:10] PHP 7. PosController->newAction() G:\Inetpub\wwwroot\php\Zend\1-9-5\library\Zend\Controller\Action.php:513 [04-Dec-2009 11:25:10] PHP 8. W_Model_Pos->makePdf() G:\Inetpub\application\w\controllers\PosController.php:9 [04-Dec-2009 11:25:10] PHP 9. Zend_Pdf::load() G:\Inetpub\application\w\models\Pos.php:17 [04-Dec-2009 11:25:10] PHP 10. Zend_Pdf->__construct() G:\Inetpub\wwwroot\php\Zend\1-9-5\library\Zend\Pdf.php:292 [04-Dec-2009 11:25:10] PHP 11. Zend_Pdf_Parser->__construct() G:\Inetpub\wwwroot\php\Zend\1-9-5\library\Zend\Pdf.php:340 [04-Dec-2009 11:25:10] PHP 12. Zend_Pdf_Parser->_loadXRefTable() G:\Inetpub\wwwroot\php\Zend\1-9-5\library\Zend\Pdf\Parser.php:471 [04-Dec-2009 11:25:34] PHP Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 118773761 bytes) in G:\Inetpub\wwwroot\php\Zend\1-9-5\library\Zend\Debug.php on line 82 [04-Dec-2009 11:25:34] PHP Stack trace: [04-Dec-2009 11:25:34] PHP 1. {main}() G:\Inetpub\wwwroot\w\index.php:0 [04-Dec-2009 11:25:34] PHP 2. Zend_Application->run() G:\Inetpub\wwwroot\w\index.php:65 [04-Dec-2009 11:25:34] PHP 3. Zend_Application_Bootstrap_Bootstrap->run() G:\Inetpub\wwwroot\php\Zend\1-9-5\library\Zend\Application.php:358 [04-Dec-2009 11:25:34] PHP 4. Zend_Controller_Front->dispatch() G:\Inetpub\wwwroot\php\Zend\1-9-5\library\Zend\Application\Bootstrap\Bootstrap.php:77 [04-Dec-2009 11:25:34] PHP 5. Zend_Controller_Dispatcher_Standard->dispatch() G:\Inetpub\wwwroot\php\Zend\1-9-5\library\Zend\Controller\Front.php:946 [04-Dec-2009 11:25:34] PHP 6. Zend_Controller_Action->dispatch() G:\Inetpub\wwwroot\php\Zend\1-9-5\library\Zend\Controller\Dispatcher\Standard.php:289 [04-Dec-2009 11:25:34] PHP 7. ErrorController->errorAction() G:\Inetpub\wwwroot\php\Zend\1-9-5\library\Zend\Controller\Action.php:513 [04-Dec-2009 11:25:34] PHP 8. Zend_Debug::dump() G:\Inetpub\application\w\controllers\ErrorController.php:25 [04-Dec-2009 11:25:34] PHP 9. var_dump() G:\Inetpub\wwwroot\php\Zend\1-9-5\library\Zend\Debug.php:82

  • it seems that the notes in red are causing the problem. Tried another pdf without the notes which worked.

Can you test the latest version please. 1.9.6. With 1.9.6 i get this Exception that points to the problem: "Cross-reference streams are not supported yet."

on 1.9.6 i get still the same error

Are you 100% sure? Because the changes from 1.9.5 to 1.9.6 changes also the lines with caused this error. If you error still happen again, where?

I still cant reproduce this bug.

http://framework.zend.com/code/browse/…

Can you maybe add a phpinfo output? Disable possible filecaching (Zend Products)

yes I am sure. Please see the attached phpinfo include path as well as the library path in the exception

[04-Dec-2009 12:38:26] PHP Notice: Indirect modification of overloaded property Zend_Pdf_Element_Object_Stream::$value has no effect in G:\Inetpub\wwwroot\php\Zend\1-9-6\library\Zend\Pdf\Parser.php on line 239 [04-Dec-2009 12:38:26] PHP Stack trace: [04-Dec-2009 12:38:26] PHP 1. {main}() G:\Inetpub\wwwroot\w\index.php:0 [04-Dec-2009 12:38:26] PHP 2. Zend_Application->run() G:\Inetpub\wwwroot\w\index.php:65 [04-Dec-2009 12:38:26] PHP 3. Zend_Application_Bootstrap_Bootstrap->run() G:\Inetpub\wwwroot\php\Zend\1-9-6\library\Zend\Application.php:358 [04-Dec-2009 12:38:26] PHP 4. Zend_Controller_Front->dispatch() G:\Inetpub\wwwroot\php\Zend\1-9-6\library\Zend\Application\Bootstrap\Bootstrap.php:77 [04-Dec-2009 12:38:26] PHP 5. Zend_Controller_Dispatcher_Standard->dispatch() G:\Inetpub\wwwroot\php\Zend\1-9-6\library\Zend\Controller\Front.php:946 [04-Dec-2009 12:38:26] PHP 6. Zend_Controller_Action->dispatch() G:\Inetpub\wwwroot\php\Zend\1-9-6\library\Zend\Controller\Dispatcher\Standard.php:289 [04-Dec-2009 12:38:26] PHP 7. PosController->newAction() G:\Inetpub\wwwroot\php\Zend\1-9-6\library\Zend\Controller\Action.php:513 [04-Dec-2009 12:38:26] PHP 8. w_Model_Pos->makePdf() G:\Inetpub\application\w\controllers\PosController.php:9 [04-Dec-2009 12:38:26] PHP 9. Zend_Pdf::load() G:\Inetpub\application\w\models\Pos.php:18 [04-Dec-2009 12:38:26] PHP 10. Zend_Pdf->__construct() G:\Inetpub\wwwroot\php\Zend\1-9-6\library\Zend\Pdf.php:253 [04-Dec-2009 12:38:26] PHP 11. Zend_Pdf_Parser->__construct() G:\Inetpub\wwwroot\php\Zend\1-9-6\library\Zend\Pdf.php:303 [04-Dec-2009 12:38:26] PHP 12. Zend_Pdf_Parser->_loadXRefTable() G:\Inetpub\wwwroot\php\Zend\1-9-6\library\Zend\Pdf\Parser.php:452 [04-Dec-2009 12:38:46] PHP Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 122429441 bytes) in G:\Inetpub\wwwroot\php\Zend\1-9-6\library\Zend\Debug.php on line 82 [04-Dec-2009 12:38:46] PHP Stack trace: [04-Dec-2009 12:38:46] PHP 1. {main}() G:\Inetpub\wwwroot\w\index.php:0 [04-Dec-2009 12:38:46] PHP 2. Zend_Application->run() G:\Inetpub\wwwroot\w\index.php:65 [04-Dec-2009 12:38:46] PHP 3. Zend_Application_Bootstrap_Bootstrap->run() G:\Inetpub\wwwroot\php\Zend\1-9-6\library\Zend\Application.php:358 [04-Dec-2009 12:38:46] PHP 4. Zend_Controller_Front->dispatch() G:\Inetpub\wwwroot\php\Zend\1-9-6\library\Zend\Application\Bootstrap\Bootstrap.php:77 [04-Dec-2009 12:38:46] PHP 5. Zend_Controller_Dispatcher_Standard->dispatch() G:\Inetpub\wwwroot\php\Zend\1-9-6\library\Zend\Controller\Front.php:946 [04-Dec-2009 12:38:46] PHP 6. Zend_Controller_Action->dispatch() G:\Inetpub\wwwroot\php\Zend\1-9-6\library\Zend\Controller\Dispatcher\Standard.php:289 [04-Dec-2009 12:38:46] PHP 7. ErrorController->errorAction() G:\Inetpub\wwwroot\php\Zend\1-9-6\library\Zend\Controller\Action.php:513 [04-Dec-2009 12:38:46] PHP 8. Zend_Debug::dump() G:\Inetpub\application\w\controllers\ErrorController.php:25 [04-Dec-2009 12:38:46] PHP 9. var_dump() G:\Inetpub\wwwroot\php\Zend\1-9-6\library\Zend\Debug.php:82

Issue is php5.3.0/win related. Investigating

fixed in trunk