Item pagination - fatal error: allowed memory exhausted I have an $items array that I was displaying with my template file. Now I want to add a pagination, therefore the code looks like this:

    $current_page = pager_default_initialize(count($items), 4);
    $chunks = array_chunk($items, 4, TRUE);

    return theme('activit_item_list_block', array('title' =&gt; $title, 'subtitle' =&gt; $subtitle, 'items' =&gt; $chunks[$current_page])).
           theme('pager', array('quantity', count($items))); 


but now im getting error: 


  Fatal error: Allowed memory size of 1342177280 bytes exhausted (tried to allocate 40961 bytes) in C:\xampp\htdocs\grantexpert\includes\theme.inc on line 1514


Can't find out what I'm doing wrong, the code is identical with few examples that i found on internet. There is only 5 items in $items array.

activit_item_list_block:

    &lt;?php $countinrow = 0; $itemcount = count($items); $counter = 0; ?&gt;

    &lt;div id="item-list"&gt;

            &lt;div class="description"&gt;&lt;?php echo rip_tags($subtitle); ?&gt;&lt;/div&gt;

            &lt;div class="cont"&gt;

                &lt;?php foreach($items as $item) { ?&gt;&lt;!-- 

                row 

            --&gt;&lt;?php $countinrow++; $counter++; if ($countinrow==1) { ?&gt;&lt;div class="row"&gt;&lt;?php } ?&gt;&lt;!-- 

                        item

                 --&gt;&lt;article class="item one-quarter"&gt;

                            &lt;img src="http://lorempixel.com/300/110/"&gt;

                            &lt;div class="cont"&gt;
                                &lt;header&gt;
                                    &lt;h3&gt;&lt;?php echo $item['title']; ?&gt;&lt;/h3&gt;
                                &lt;/header&gt;
                                &lt;div class="text"&gt;
                                    &lt;?php echo $item['text']; ?&gt;
                                &lt;/div&gt;
                            &lt;/div&gt;

                            &lt;a class="button btn-small" href="/&lt;?php echo $item['link']; ?&gt;"&gt;Viac informácií&lt;/a&gt;

                        &lt;/article&gt;&lt;!-- 

                        END OF item 

             --&gt;&lt;?php if ($countinrow==4 || $counter==$itemcount) { $countinrow = 0; ?&gt;&lt;/div&gt;&lt;?php } ?&gt;&lt;!-- END OF row 

                &lt;?php } ?&gt;

     --&gt;&lt;/div&gt;

    &lt;/div&gt;
I'm not sure what theme_activit_item_list_block() is but I suspect you want this:

theme('pager', array('quantity' =&gt; count($items)));


instead of this:

theme('pager', array('quantity', count($items)));