Answers.Body: <p>Use <code>.total()</code> instead of <code>.count()</code></p>
  
  <p><code>.count()</code> will query the db and fetch all fields for all items relating to your criteria and then count them. </p>
  
  <p><code>.total()</code> only counts the number of items your criteria returns without all of their fields. </p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-04-15T13:55:44.423Z
Answers.LastActivityDate: 2016-04-15T13:55:44.423Z
Answers.UserDisplayName: Luke Pearce
Answers.Body: <p>In addition to <a href="https://craftcms.stackexchange.com/a/14669/57">Luke's answer</a>, you might want to consider bumping your php.ini file's <a href="https://secure.php.net/manual/en/ini.core.php#ini.memory-limit" rel="nofollow noreferrer">memory_limit</a> to something higher than 128M, like 256M.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-04-15T14:15:17.383Z
Answers.LastActivityDate: 2016-04-15T14:15:17.383Z
Answers.LastEditDate: 2017-04-13T12:51:00.200Z
Answers.UserDisplayName: Brad Bell
Body: <p>Hi I have like 2000 users in my system. I would like to get a count of the active ones, so I did it like this:</p>
  
  <pre><code>{{craft.users.group('member').count()}}
  </code></pre>
  
  <p>but this returns the count with the limit of 100, so when I remove the limit</p>
  
  <pre><code>{{craft.users.group('member').limit(null).count()}}
  </code></pre>
  
  <p>I got this error</p>
  
  <pre><code>Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 32 bytes) in /Users/alex/git/website/craft/app/models/BaseModel.php on line 280
  </code></pre>
  
Tags: <users><error><memory><count>
Title: Count users, not enough memory error
ThreadText: # Count users, not enough memory error
  
  (Asked by: username_0 on 2016-04-15)
  
  Hi I have like 2000 users in my system. I would like to get a count of the active ones, so I did it like this:
  
  ```
  {{craft.users.group('member').count()}}
  
  ```
  
  but this returns the count with the limit of 100, so when I remove the limit
  
  ```
  {{craft.users.group('member').limit(null).count()}}
  
  ```
  
  I got this error
  
  ```
  Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 32 bytes) in /Users/username_0/git/website/craft/app/models/BaseModel.php on line 280
  
  ```
  
  **Tags:** users, error, memory, count
  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_1 on 2016-04-15. Score: 3 | Accepted answer
  
  Use `.total()` instead of `.count()`
  
  `.count()` will query the db and fetch all fields for all items relating to your criteria and then count them.
  
  `.total()` only counts the number of items your criteria returns without all of their fields.
  
  
  ---
  
  ### Answer by username_2 on 2016-04-15. Score: 0
  
  In addition to [username_1's answer](https://craftcms.stackexchange.com/a/14669/57), you might want to consider bumping your php.ini file's [memory\_limit](https://secure.php.net/manual/en/ini.core.php#ini.memory-limit) to something higher than 128M, like 256M.
  
  
  ---
  
  