title: Memory exhausted even when there is a lot of memory allocated
body: <p>I realize that there are a lot of similar threads and I checked all of them. I've tried to increase the memory limit in <code>php.ini</code>, <code>wp-config.php</code>, <code>wp-settings.php</code> but nothing help. </p>
  
  <p>Current error is:</p>
  
  <blockquote>
    <p>Fatal error: Allowed memory size of 67108864 bytes exhausted (tried to allocate 72 bytes) in /home/xxx/public_html/wp-includes/wp-db.php on line 2516</p>
  </blockquote>
  
  <p>My limits in php.ini are</p>
  
  <pre><code>;;;;;;;;;;;;;;;;;;;
  ; Resource Limits ;
  ;;;;;;;;;;;;;;;;;;;
  
  max_execution_time = 3600
  max_input_time = 3600
  max_input_vars = 1000
  memory_limit = 8192M
  post_max_size = 256M
  </code></pre>
  
  <p>I don't know what to increase anymore. </p>
  
  <p>edit: <code>phpinfo()</code> shows this</p>
  
  <p><a href="https://i.stack.imgur.com/4jGBE.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/4jGBE.png" alt="enter image description here"></a></p>
  
  <p>Edit: <code>wp-db.php</code></p>
  
  <p>Error is here: </p>
  
  <pre><code> else {
              // ...column name-keyed row arrays
              $new_array[] = get_object_vars( $row );
   }
  </code></pre>
  
  <p>and this is the full function (sorry for the long code)</p>
  
  <pre><code>    /**
   * Retrieve an entire SQL result set from the database (i.e., many rows)
   *
   * Executes a SQL query and returns the entire SQL result.
   *
   * @since 0.71
   *
   * @param string $query  SQL query.
   * @param string $output Optional. Any of ARRAY_A | ARRAY_N | OBJECT | OBJECT_K constants.
   *                       With one of the first three, return an array of rows indexed from 0 by SQL result row number.
   *                       Each row is an associative array (column =&gt; value, ...), a numerically indexed array (0 =&gt; value, ...), or an object. ( -&gt;column = value ), respectively.
   *                       With OBJECT_K, return an associative array of row objects keyed by the value of each row's first column's value.
   *                       Duplicate keys are discarded.
   * @return array|object|null Database query results
   */
  public function get_results( $query = null, $output = OBJECT ) {
      $this-&gt;func_call = "\$db-&gt;get_results(\"$query\", $output)";
  
      if ( $this-&gt;check_current_query &amp;&amp; $this-&gt;check_safe_collation( $query ) ) {
          $this-&gt;check_current_query = false;
      }
  
      if ( $query ) {
          $this-&gt;query( $query );
      } else {
          return null;
      }
  
      $new_array = array();
      if ( $output == OBJECT ) {
          // Return an integer-keyed array of row objects
          return $this-&gt;last_result;
      } elseif ( $output == OBJECT_K ) {
          // Return an array of row objects with keys from column 1
          // (Duplicates are discarded)
          foreach ( $this-&gt;last_result as $row ) {
              $var_by_ref = get_object_vars( $row );
              $key = array_shift( $var_by_ref );
              if ( ! isset( $new_array[ $key ] ) )
                  $new_array[ $key ] = $row;
          }
          return $new_array;
      } elseif ( $output == ARRAY_A || $output == ARRAY_N ) {
          // Return an integer-keyed array of...
          if ( $this-&gt;last_result ) {
              foreach ( (array) $this-&gt;last_result as $row ) {
                  if ( $output == ARRAY_N ) {
                      // ...integer-keyed row arrays
                      $new_array[] = array_values( get_object_vars( $row ) );
                  } else {
                      // ...column name-keyed row arrays
                      $new_array[] = get_object_vars( $row );
                  }
              }
          }
          return $new_array;
      } elseif ( strtoupper( $output ) === OBJECT ) {
          // Back compat for OBJECT being previously case insensitive.
          return $this-&gt;last_result;
      }
      return null;
  }
  </code></pre>