I'm looking at a site with 512M that is running out of memory on admin/config.
PHP Fatal error: Allowed memory size of 536870912 bytes exhausted (tried to allocate 83 bytes) in .../includes/entity.inc on line 1316
Using strace it appears that memory is running out trying to load results of the following query:
SELECT
field_data_group_group0.entity_type AS entity_type,
field_data_group_group0.entity_id AS entity_id,
field_data_group_group0.revision_id AS revision_id,
field_data_group_group0.bundle AS bundle
FROM field_data_group_group field_data_group_group0
WHERE (field_data_group_group0.group_group_value = '1')
AND (field_data_group_group0.deleted = '0')
AND (field_data_group_group0.entity_type = 'user')
In this particular install, this result set has 223032 rows.
Backtrace:
- EntityFieldQuery::finishQuery [./includes/entity.inc@1316]
- Called by field_sql_storage_field_storage_query [field_sql_storage.module@585]
- Called by EntityFieldQuery::execute [./ncludes/entity.inc@1140]
- Called by og_get_all_group [og.module@1850]
- Called by commons_trusted_contacts_requirements [commons_trusted_contacts.install@22]
- if ($count > count(og_get_all_group('user'))) {
I'm not sure if this is more a problem with Organic Groups not providing a more lightweight method, or Commons Trusted Contacts asking for more info than it needs; but thought to start here for solutions.
Thanks much!
Comments
Comment #1
ezra-g commentedThanks for the report here. On which page do you experience this problem?
Comment #2
JvE commentedI also run out of memory when doing an EntityFieldQuery which returns a lot of node ids.
For my content it appears to consume about 2KB of memory for every result.
Querying 100K nodes will consume about 200MB.
I solved it by splitting my EntityFieldQueries into ranges which size I make depend on available memory.
Comment #3
ezra-g commented@JvE, Can you answer the question in #1?
Comment #4
JvE commentedNo, I'm not even using Drupal Commons.
From the backtrace in the OP you can see that OG function og_get_all_group() uses an EntityFieldQuery.
I'm just saying that EntityFieldQueries consume a lot of memory if there are a lot of results
The OP has 223032 results, which will consume about 400MB of memory in EntityFieldQuery.
On which page the EntityFieldQuery is executed is irrelevant.
Either OG should change the way og_get_all_group() works, or commons_trusted_contacts should not call og_get_all_group('user').
*edit:
I took a look at commons_trusted_contacts_requirements() and it seems to use og_get_all_group('user') to get a count of "group users"
A better approach would be to use a count EntityFieldQuery like:
much less resource intensive.
Comment #5
ezra-g commentedMy goal in asking about the page or action where this occurs is to understand the code flow so that we can a) know what Commons is trying to do that causes this situation and b) pursue alternatives.
Comment #6
JvE commentedOP lists the page as 'admin/config' but really it would be any page that invokes hook_requirements.
Comment #7
ezra-g commentedThis is fixed with http://drupalcode.org/project/commons.git/commitdiff/8230dd3?hp=7ada96c2... .