Increase memory limit

前端 未结 4 823
一生所求
一生所求 2021-01-22 08:45

My php script creates PDF on fly, the data comes from mysql db table it works fine till 30 records but more than that it says

I am dompdf from http://code.google.com/p/

相关标签:
4条回答
  • 2021-01-22 09:04

    Ok thanks to all I just need to set memory_limit = 94G in dompdf class and now it is creating large pdf but after some minutes browser says "The connection was reset - The connection to the server was reset while the page was loading. etc...." although I increase the execution time up to 3600 sec //ini_set('max_execution_time', 3600)

    0 讨论(0)
  • 2021-01-22 09:05

    45 bytes is not the limit - 33554432 is the limit, which is 32M. 45 bytes is just a block that PHP tried to allocate and failed (which is not very useful since it could be anything). Check that you are actually editing correct php.ini and it actually is reflected in your phpinfo(). 96550M btw is 94G of memory - do you really have that much? Try to unset objects you are not using and also try to run gc cycle via gc_collect_cycles (see: http://www.php.net/manual/en/function.gc-collect-cycles.php ) manually.

    0 讨论(0)
  • 2021-01-22 09:10

    go through below code. update code and comment as per your requirement

    <?php
    
        echo '<h1>System Configuration</h1>';
        echo '<br>';
    
        //PHP SETUP: all time in seconds
    
        //ini_set('max_execution_time', 18000);  // set your max execution time that you require for current script
        //ini_set('memory_limit',' 2048M'); //  set memory limit that you require for current script
        //ini_set("max_input_time", '5000');
        //ini_set('default_socket_timeout', '5000');    
        //@set_time_limit(0);
    
        //DATABASE SETUP: all time in seconds
        //ini_set('mysql.connect_timeout', '5000');
    
    
        $ini_path       = php_ini_loaded_file();
        $ini_max_time   = ini_get('max_execution_time');
        $ini_memory     = ini_get('memory_limit');          
    
    ?>
    <div class="hdr">Current Server</div>
    <label>Web Server : </label> <?php echo $_SERVER['SERVER_SOFTWARE']; ?><br/>
    <label>Operating System : </label><?php echo PHP_OS ?><br/>
    <label>PHP Version : </label><?php echo phpversion(); ?><br/>
    <label>PHP INI Path : </label><?php echo empty($ini_path ) ? 'Unable to detect loaded php.ini file' : $ini_path; ?><br/>
    <label>PHP SAPI : </label><?php echo php_sapi_name(); ?><br/>
    <label>PHP ZIP Archive : </label> <?php echo class_exists('ZipArchive') ? 'Is Installed' : 'Not Installed'; ?> <br/>
    <label>PHP max_execution_time:</label> <?php echo $ini_max_time === false ? 'unable to find' : $ini_max_time; ?><br/>
    <label>PHP memory_limit : </label> <?php echo empty($ini_memory) ? 'unable to find' : $ini_memory; ?><br/>
    
    0 讨论(0)
  • 2021-01-22 09:26

    use the following on the top of your page:

     ini_set('max_execution_time', 3000);
     ini_set('memory_limit','16M');
    

    This setting is valid for your current script only.

    0 讨论(0)
提交回复
热议问题