I've got a lot of entity forms and when accessing /admin/help/token, I've the following error:

PHP Fatal error: Allowed memory size of 6442450944 bytes exhausted at /private/tmp/php5620160415-23041-14wfk5o/php-5.6.20/ext/standard/string.c:2994 (tried to allocate 4104 bytes) in contrib/token/token.pages.inc on line 233

Fatal error:  Allowed memory size of 6442450944 bytes exhausted at /private/tmp/php5620160415-23041-14wfk5o/php-5.6.20/ext/standard/string.c:2994 (tried to allocate 4104 bytes) in sites/all/modules/contrib/token/token.pages.inc on line 233
Stack trace:
  1. {main}() .ht.router.php:0
  2. require() .ht.router.php:45
  3. menu_execute_active_handler($path = *uninitialized*, $deliver = *uninitialized*) index.php:21
  4. call_user_func_array:{includes/menu.inc:527}('help_page', array (0 => 'token')) includes/menu.inc:527
  5. help_page($name = 'token') includes/menu.inc:527
  6. module_invoke($module = 'token', $hook = 'help', 'admin/help#token', array (0 => '', 1 => '', 2 => '', 3 => '', 4 => '', 5 => '', 6 => '', 7 => '', 8 => '', 9 => '', 10 => '', 11 => '')) modules/help/help.admin.inc:30
  7. call_user_func_array:{includes/module.inc:922}('token_help', array (2 => 'admin/help#token', 3 => array (0 => '', 1 => '', 2 => '', 3 => '', 4 => '', 5 => '', 6 => '', 7 => '', 8 => '', 9 => '', 10 => '', 11 => ''))) includes/module.inc:922
  8. token_help($path = 'admin/help#token', $arg = array (0 => '', 1 => '', 2 => '', 3 => '', 4 => '', 5 => '', 6 => '', 7 => '', 8 => '', 9 => '', 10 => '', 11 => '')) includes/module.inc:922
  9. theme($hook = 'token_tree', $variables = array ('token_types' => 'all', 'click_insert' => FALSE, 'show_restricted' => TRUE)) sites/all/modules/contrib/token/token.module:26
 10. theme_token_tree($variables = array ('token_types' => 'all', 'click_insert' => FALSE, 'show_restricted' => TRUE, 'global_types' => TRUE, 'recursion_limit' => 3, 'dialog' => FALSE, 'theme_hook_original' => 'token_tree')) includes/theme.inc:1161
 11. _token_token_tree_format_row($token = '[entityform:field-details-of-new-licence-:field-evidence-offline-group:field-number-10]', $token_info = array ('name' => 'Quantity needed', 'description' => 'Field "field_number_10".', 'type' => 'text', 'entity-token' => TRUE, 'raw token' => '[entityform:field-details-of-new-licence-:field-evidence-offline-group:field-number-10]', 'token' => 'field-details-of-new-licence-:field-evidence-offline-group:field-number-10', 'parent' => '[entityform:field-details-of-new-licence-:field-evidence-offline-group]', 'children' => array ()), $is_group = *uninitialized*) sites/all/modules/contrib/token/token.pages.inc:148
 12. _token_clean_css_identifier($id = '[entityform:field-details-of-new-licence-:field-evidence-offline-group]') sites/all/modules/contrib/token/token.pages.inc:216
 13. strtr('entityform:field-details-of-new-licence-:field-evidence-offline-group', array (' ' => '-', '_' => '-', '/' => '-', '[' => '-', ']' => '', ':' => '--', '?' => '', '<' => '-', '>' => '-')) sites/all/modules/contrib/token/token.pages.inc:233

6G is a huge amount of memory and this doesn't happen on any other pages which are memory hungry as well.

This seemed to be improved in #1068990: Optimize and add caching for theme_token_tree(), but I've got still the problem.

I've tried to increase to 8G, but it's probably not enough.

I've attached html file which reaches 7.7G and fails over 240 seconds.

Another tried end up hitting 8G limit:

Fatal error:  Allowed memory size of 8589934592 bytes exhausted at /private/tmp/php5620160415-23041-14wfk5o/php-5.6.20/Zend/zend_hash.c:320 (tried to allocate 64 bytes) in sites/all/modules/contrib/token/token.pages.inc on line 77
Stack trace:
  1. {main}() .ht.router.php:0
  2. require() .ht.router.php:45
  3. menu_execute_active_handler($path = *uninitialized*, $deliver = *uninitialized*) index.php:21
  4. call_user_func_array:{includes/menu.inc:527}('help_page', array (0 => 'token')) includes/menu.inc:527
  5. help_page($name = 'token') includes/menu.inc:527
  6. module_invoke($module = 'token', $hook = 'help', 'admin/help#token', array (0 => '', 1 => '', 2 => '', 3 => '', 4 => '', 5 => '', 6 => '', 7 => '', 8 => '', 9 => '', 10 => '', 11 => '')) modules/help/help.admin.inc:30
  7. call_user_func_array:{includes/module.inc:922}('token_help', array (2 => 'admin/help#token', 3 => array (0 => '', 1 => '', 2 => '', 3 => '', 4 => '', 5 => '', 6 => '', 7 => '', 8 => '', 9 => '', 10 => '', 11 => ''))) includes/module.inc:922
  8. token_help($path = 'admin/help#token', $arg = array (0 => '', 1 => '', 2 => '', 3 => '', 4 => '', 5 => '', 6 => '', 7 => '', 8 => '', 9 => '', 10 => '', 11 => '')) includes/module.inc:922
  9. theme($hook = 'token_tree', $variables = array ('token_types' => 'all', 'click_insert' => FALSE, 'show_restricted' => TRUE)) sites/all/modules/contrib/token/token.module:26
 10. theme_token_tree($variables = array ('token_types' => 'all', 'click_insert' => FALSE, 'show_restricted' => TRUE, 'global_types' => TRUE, 'recursion_limit' => 3, 'dialog' => FALSE, 'theme_hook_original' => 'token_tree')) includes/theme.inc:1161
 11. drupal_render(...) includes/theme.inc:1161

I don't have any extra consuming memory modules. I've Devel disabled, and no any other development modules, even disabling dblog didn't help.

So I just wondering if there is any way to improve it further.

Files: 

Comments

kenorb created an issue. See original summary.

kenorb’s picture

Issue summary: View changes
FileSize
176.35 KB
kenorb’s picture

Maybe some implementation of paging at /admin/help/token, so theme_token_tree() won't have to deal with all possible tokens?

kenorb’s picture

Title: Token consumes more than 4G of memory to render all the tokens. » Token consumes more than 8G of memory to render all the tokens.
Issue summary: View changes
JordanMagnuson’s picture

Any news on this?

Latest version of Token has mostly been working okay for me, but when I try to edit a menu entry in my main menu, I'm getting a broken error page and the following in my Apache error log:

Allowed memory size of 536870912 bytes exhausted (tried to allocate 77 bytes) in /srv/www/pixelscrapper.com/public_html/sites/all/modules/token/token.pages.inc on line 77, referer: https://www.pixelscrapper.com/admin/structure/menu/manage/main-menu

JordanMagnuson’s picture

Version: 7.x-1.6 » 7.x-1.7
nscad_nathan’s picture

I'm in the same boat. Would like to figure out a solution...

C13L0’s picture

I would recommend to try Token Tweaks and limit the tree to two. Token Tweaks helps when accessing the token tree ui by limiting the depth of displayed tokens which stops memory errors.