Answers.Body: <p>Your <code>php.ini</code> file's <a href="https://secure.php.net/manual/en/ini.core.php#ini.memory-limit" rel="nofollow noreferrer"><code>memory_limit</code></a> setting is set to <code>32M</code>.</p>
  
  <p>You'll want to bump that up to something higher like <code>256M</code>.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-02-15T19:27:50.017Z
Answers.Text: Am i running a the risk of overloading the memory on the site though? It seems surprising that such a simple query would be so demanding on memory.
Answers.UserDisplayName: Noah Yamen
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-02-15T19:54:27.753Z
Answers.Text: Probably not? 32M is a pretty low memory limit setting.
Answers.UserDisplayName: Brad Bell
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-02-15T19:56:25.990Z
Answers.Text: Good to know. Updated it and its running fine now, as would be expected.
Answers.UserDisplayName: Noah Yamen
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-02-15T19:24:42.153Z
Answers.LastActivityDate: 2017-02-15T19:24:42.153Z
Answers.UserDisplayName: Brad Bell
Body: <p>Trying to get this json api to work for us and keep running into issues. Here, when trying to list all items, it throws the following PHP error:</p>
  
  <blockquote>
    <p>Fatal error:  Allowed memory size of 33554432 bytes exhausted (tried to allocate 65552 bytes) in /home/accesstrucks/craft/app/framework/YiiBase.php on line 618</p>
  </blockquote>
  
  <p>There are only 100 listings currently, but this is just for testing. Which is nothing compared to how many listings there will be when live. </p>
  
  <p>Here's my code: </p>
  
  <pre><code>return [
    'endpoints' =&gt; [
      'alltrucks.json' =&gt; [
        'elementType' =&gt; 'Entry',
        'criteria' =&gt; ['section' =&gt; 'trucks'],
        'paginate' =&gt; false,
        'transformer' =&gt; function(EntryModel $entry) {
          return [
            $entry-&gt;year.' '.$entry-&gt;manufacturer.' '.$entry-&gt;model,
            (string)$entry-&gt;author,
            !empty((string)$entry-&gt;category[0]) ? (string)$entry-&gt;category[0] : null, 
            !empty($entry-&gt;listingPhotos[0]-&gt;url) ? str_replace('/images/uploads/listings/', '', $entry-&gt;listingPhotos[0]-&gt;url) : null,
            ($entry-&gt;saleType=='new') ? '0' : '1',
            (string)$entry-&gt;featured,
            ($entry-&gt;saleType-&gt;label=='new') ? '0' : '1',
            $entry-&gt;transmission,
            (string)$entry-&gt;dateUpdated,
            $entry-&gt;mileage,
            $entry-&gt;price
  </code></pre>
  
Tags: <plugin-elementapi>
Title: Element API: PHP Error: Fatal error: Allowed memory size of 33554432 bytes exhausted
ThreadText: # Element API: PHP Error: Fatal error: Allowed memory size of 33554432 bytes exhausted
  
  (Asked by: username_0 on 2017-02-15)
  
  Trying to get this json api to work for us and keep running into issues. Here, when trying to list all items, it throws the following PHP error:
  
  > Fatal error: Allowed memory size of 33554432 bytes exhausted (tried to allocate 65552 bytes) in /home/accesstrucks/craft/app/framework/YiiBase.php on line 618
  
  There are only 100 listings currently, but this is just for testing. Which is nothing compared to how many listings there will be when live.
  
  Here's my code:
  
  ```
  return [
    'endpoints' => [
      'alltrucks.json' => [
        'elementType' => 'Entry',
        'criteria' => ['section' => 'trucks'],
        'paginate' => false,
        'transformer' => function(EntryModel $entry) {
          return [
            $entry->year.' '.$entry->manufacturer.' '.$entry->model,
            (string)$entry->author,
            !empty((string)$entry->category[0]) ? (string)$entry->category[0] : null, 
            !empty($entry->listingPhotos[0]->url) ? str_replace('/images/uploads/listings/', '', $entry->listingPhotos[0]->url) : null,
            ($entry->saleType=='new') ? '0' : '1',
            (string)$entry->featured,
            ($entry->saleType->label=='new') ? '0' : '1',
            $entry->transmission,
            (string)$entry->dateUpdated,
            $entry->mileage,
            $entry->price
  
  ```
  
  **Tags:** plugin-elementapi
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2017-02-15. Score: 0 | Accepted answer
  
  Your `php.ini` file's [`memory_limit`](https://secure.php.net/manual/en/ini.core.php#ini.memory-limit) setting is set to `32M`.
  
  You'll want to bump that up to something higher like `256M`.
  
  > **Comments:**
  > **username_0**: Am i running a the risk of overloading the memory on the site though? It seems surprising that such a simple query would be so demanding on memory.  
  > **username_1**: Probably not? 32M is a pretty low memory limit setting.  
  > **username_0**: Good to know. Updated it and its running fine now, as would be expected.  
  
  ---
  
  