title: TCPDF Memory Issue Allowed memory size of 134217728 bytes exhausted
body: <p>I am using TCPDF for downloading PDF. For smaller records, it is working fine.But for large data ie 1000 records, it is showing the following error,</p>
  
  <pre><code>Fatal error:  Maximum execution time of 30 seconds exceeded
  Fatal error:  Allowed memory size of 134217728 bytes exhausted (tried to allocate 72 bytes)
  </code></pre>
  
  <p>I have set memory limit and max execution time in php using ini_set But it not works.I also tried changing the value of memory_limit in php.ini from 128M to 512M.This also not working.</p>
  
  <p>My file is</p>
  
  <pre><code> &lt;html lang="en"&gt;
      &lt;head&gt;
          &lt;meta charset="utf-8"&gt;
          &lt;meta http-equiv="X-UA-Compatible" content="IE=edge"&gt;
          &lt;meta name="viewport" content="width=device-width, initial-scale=1"&gt;
          &lt;meta name="description" content=""&gt;
          &lt;meta name="author" content=""&gt;
          &lt;title&gt;Customer Receipts Report&lt;/title&gt;
          &lt;!-- Bootstrap Core CSS --&gt;
  
          &lt;style&gt;
               @font-face {
              font-family: SourceSansPro;
    src: url(../../fonts/SourceSansPro-Regular.ttf);
  /*  font-family: Roboto;
    src: url(../fonts/Roboto-Regular.ttf);*/
  }
  table {
    width: 100%;
    border-collapse: collapse;
    border-spacing: 0;
    margin-bottom: 20px;
     font-family:"Armata", sans-serif;
  }
  
  table th,
  table td {
    padding: 5px;
    background: #EEEEEE;
    text-align: center;
    border-bottom: 1px solid #FFFFFF;
  }
  
  table th {
    white-space: nowrap;        
    font-weight: normal;
    background: #4A7171;
    color:white;
    font-size:12px;
  }
              html,body{
                  overflow: hidden;
              }
              .login{color:#fff}
              .table-responsive table td
              {
                  font-weight: 400;
                  font-size: 12px;
                  color:#222;
                  text-align:center !important;
              } 
              .form-control {
                  border:1px solid #eee;
              }
              .input-sm
              {
                  border-radius: 3px;
              }
              input.input-sm
              {
                  margin-left: 10px
              }
              #dataTables-example_info,#dataTables-example_length label
              {
                  color:#666;
              }
              #dataTables-example_wrapper {
    width: 86.5% !important;
  }
              label{
                  text-transform: lowercase;
              }
              .black_overlay{
      display: none;
      position: absolute;
      top: 0%;
      left: 0%;
      width: 100%;
      height: 100%;
      background-color: grey;
      z-index:1001;
      -moz-opacity: 0.8;
      opacity:.80;
      filter: alpha(opacity=80);
          }
  
          .white_content {
                  display: none;
                  position: fixed;
                  top: 7%;
                  left: 20%;
                  padding: 16px;
                  border: 2px solid #7B8D8C;
                  background-color: white;
                  z-index:1002;
                  overflow: auto;
                  height:auto;                                
                  width: 30cm;  
                  height: 35cm;   
                  overflow-y: scroll;
                  max-height: 700px;
          }
          #wrapper {width:auto ;margin-bottom:5px;}
          #left{
          float:left;
          width:45%;
          /*background:#7B8D8C*/
  
          }
          #right{
          /*background:#7B8D8C;*/
          float:right;
          width:45%;
          height:50%;
          }
  
      &lt;/style&gt;
      &lt;/head&gt;
      &lt;body&gt;
  
              &lt;div id="page-wrapper"&gt;
                  &lt;div class="row"&gt;
                      &lt;div class="col-lg-12"&gt;
                          &lt;div class="panel-body"&gt;
                             &lt;table style='width:100%;' border=0&gt;
  &lt;tr&gt;
  &lt;td style='vertical-align:top;text-align:left;background-color:black;'&gt;&lt;img src="../../images/logo.png" style="width:140px;margin-left: 20px"/&gt;&lt;/td&gt;
  &lt;td colspan=2 style='background-color:black;color:white;font-size:9px;'&gt; &lt;div style='text-align:right;'&gt;
          &lt;div&gt;Company&lt;/div&gt;
          &lt;div&gt;Address&lt;/div&gt;
          &lt;div&gt;Address&lt;/div&gt;
          &lt;div style='color:white !important;'&gt;&lt;a href="mailto:info@gmail.com" style='text-decoration:none;'&gt;info@gmail.com &lt;/a&gt;&lt;/div&gt;
        &lt;/div&gt;
  &lt;/td&gt;&lt;/tr&gt;
      &lt;/table&gt;
  
  
                                   &lt;div class="table-responsive"&gt;
                                           &lt;br&gt;
  
                                            &lt;h3 class="page-header" style="text-align:center;"&gt;&lt;i class="fa fa-road fa-fw" style="padding-right:10px;"&gt;&lt;/i&gt; Receipts Report &lt;/h3&gt;
                                  &lt;table class="table table-striped table-bordered table-hover" id="dataTables-example" style='width:100% !important;'&gt;
                                      &lt;thead&gt; 
                                          &lt;tr style="background-color:black;color:white;"&gt;
                                            &lt;th&gt;&lt;i class="fa fa-user"&gt;&lt;/i&gt; Customer Name&lt;/th&gt;
                                              &lt;th&gt;&lt;b&gt;#&lt;/b&gt; Invoice Number&lt;/th&gt;
                                              &lt;th&gt;&lt;i class="fa fa-calendar"&gt;&lt;/i&gt; Invoice Date&lt;/th&gt; 
                                               &lt;th &gt;&lt;i class="fa fa-calendar"&gt;&lt;/i&gt; Due date&lt;/th&gt; 
  
                                               &lt;th&gt;&lt;i class="fa fa-credit-card"&gt;&lt;/i&gt; Payment Status&lt;/th&gt; 
                                              &lt;th&gt;&lt;i class="fa fa-dollar" style="min-width:10px"&gt;&lt;/i&gt; Amount&lt;/th&gt;                         
  
                                          &lt;/tr&gt;
                                      &lt;/thead&gt;
                                      &lt;tbody&gt;
                                          &lt;?php
                                          $total=0;
                                          for($i=0;$i&lt;count($obj['ar_info']);$i++){
  
                                              echo "&lt;tr&gt;&lt;td&gt;".$obj['ar_info'][$i]['customer_name']."&lt;/td&gt;&lt;td&gt;".$obj['ar_info'][$i]['invoice_number']."&lt;/td&gt;&lt;td&gt;".$obj['ar_info'][$i]['invoice_date']."&lt;/td&gt;&lt;td&gt;".$obj['ar_info'][$i]['due_date']."&lt;/td&gt;&lt;td&gt;".$obj['ar_info'][$i]['payment_status']."&lt;/td&gt;&lt;td&gt;".$obj['ar_info'][$i]['invoice_amt']."&lt;/td&gt;&lt;/tr&gt;";
  
                                          }
                                          ?&gt;
                                      &lt;/tbody&gt;
                                  &lt;/table&gt;
  
                              &lt;/div&gt;
                              &lt;!-- /.table-responsive --&gt;  
  
                          &lt;/div&gt;
                          &lt;!-- /.panel-body --&gt;
                      &lt;/div&gt;
                      &lt;!-- /.col-lg-12 --&gt;
                  &lt;/div&gt;
  
              &lt;/div&gt;
  
  
          &lt;/div&gt;   
  
  
      &lt;/body&gt;
  &lt;/html&gt;
  
  
  
  
     $pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
  
  $pdf-&gt;SetCreator(PDF_CREATOR);
  //$pdf-&gt;SetAuthor('Nicola Asuni');
  //$pdf-&gt;SetTitle('TCPDF Example 049');
  //$pdf-&gt;SetSubject('TCPDF Tutorial');
  //$pdf-&gt;SetKeywords('TCPDF, PDF, example, test, guide');
  
  $pdf-&gt;SetHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, PDF_HEADER_TITLE.' 049', PDF_HEADER_STRING);
  
  $pdf-&gt;setHeaderFont(Array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN));
  $pdf-&gt;setFooterFont(Array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA));
  
  $pdf-&gt;SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);
  
  $pdf-&gt;SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT);
  $pdf-&gt;SetHeaderMargin(PDF_MARGIN_HEADER);
  $pdf-&gt;SetFooterMargin(PDF_MARGIN_FOOTER);
  
  $pdf-&gt;SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM);
  
  $pdf-&gt;setImageScale(PDF_IMAGE_SCALE_RATIO);
  
  if (@file_exists(dirname(__FILE__).'/lang/eng.php')) {
      require_once(dirname(__FILE__).'/lang/eng.php');
      $pdf-&gt;setLanguageArray($l);
  }
  $pdf-&gt;SetFont('helvetica', '', 10);
  
  $pdf-&gt;AddPage();
  //$html = '&lt;h1&gt;Test TCPDF Methods in HTML&lt;/h1&gt;
  //&lt;h2 style="color:red;"&gt;IMPORTANT:&lt;/h2&gt;
  //&lt;span style="color:red;"&gt;If you are using user-generated content, the tcpdf tag can be unsafe.&lt;br /&gt;
  //You can disable this tag by setting to false the &lt;b&gt;K_TCPDF_CALLS_IN_HTML&lt;/b&gt; constant on TCPDF configuration file.&lt;/span&gt;
  //&lt;h2&gt;write1DBarcode method in HTML&lt;/h2&gt;';
  $pdf-&gt;writeHTML($html, true, 0, true, 0);
  
  $pdf-&gt;lastPage();
  ob_end_clean();
  $pdf-&gt;Output('example_049.pdf', 'I');
  header('Content-type: application/pdf');
  header('Content-Disposition: inline; filename="file.pdf"');
  header('Content-Transfer-Encoding: binary');
  header('Content-Length: ' . filesize('customer-receipts-report.pdf'));
  header('Accept-Ranges: bytes');
  readfile('customer-receipts-report.pdf');
  ob_end_flush(); 
  </code></pre>
  
  <p>Please anyone help me on this issue.</p>