When trying to add a Link (7.x-1.1) field to a content type with multiple fields I receive the following:

Fatal error: Allowed memory size of 268435456 bytes exhausted (tried to allocate 78 bytes) in /home/xxx/public_html/sites/all/modules/token/token.pages.inc on line 71

Comments

moonray’s picture

Priority: Normal » Major

When trying to 'Browse available tokens' on /admin/config/people/accounts
Fatal error: Allowed memory size of 536870912 bytes exhausted (tried to allocate 79 bytes) in ../sites/all/modules/token/token.pages.inc on line 228

That's a crazy amount of memory required.

penyaskito’s picture

Same issue in some random page that lists the table of available tokens.

penyaskito’s picture

Issue is at theme_token_tree() if we have a lot of items.

What approach could we take on this? Ajax loading of tokens? Pagination?

moonray’s picture

nigelheinsius’s picture

I believe I was having memory problems on my "admin/structure/types/manage/content-type-xx" page. I use Automatic Nodetitles which leverages token to set custom page titles and the settings for this are on the edit content type page. The fix? I installed the "token_tweaks" module to limit the depth of the tokens built for the token tree for Automatic Nodetitles from 4 to 2 and my problem was solved.

Renee S’s picture

nigelheinsius: This solves the problem... but it means you can't see what tokens you have available. I consider that a huge deal.

mvonfrie’s picture

I have a similar issue but at another place:
PHP Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 523800 bytes) in /var/www/drupal7/sites/all/modules/token/token.tokens.inc on line 895

This is the [custom:hash:*] dynamic token block inside the token_tokens() implementation. The strange thing is, that it only occurs when the user is logged in and doesn't have a certain permission. I want to create an "editor" role on my side. When this role has all permissions (as administrator) I can login with the user, when I remove permissions it crashes. I haven't found out yet which permission is causing it.

Update:
This is caused by the Administer Organic groups permission.

Renee S’s picture

mvonrie: It's likely that tokens are being added by OG that are pushing your site over the edge. You can either give it more memory (sigh) or use the Token Tweaks module to cut down on the token depths being displayed on any given form.

mvonfrie’s picture

Renee: Thanks but it doesn't help. I've increased memory from 128MB to 256 MB and set token depth to down to 1 with Token Tweaks. Now I get no response from the server and not even an entry in PHP error log.

thuzyanth’s picture

How to increase Allowed memory size ?

mvonfrie’s picture

I already have increased memory by 100% and more is not possible (shared hosting). Yesterday I talked to some people at DrupalCamp Vienna and for them it seems to be an endless loop.

bassplaya’s picture

@nigelheinsius, yeah man! Awesome! This rocks. I was so fed up with the overload on my site because of this issue and indeed Token Tweaks is a great solution for my PDOException issue here: https://drupal.org/comment/8213899#comment-8213899

before installing this module:
admin/structure/types/manage/my-story-type:
Page execution time was 2114.85 ms. Memory used at: devel_boot()=3.86 MB, devel_shutdown()=73.22 MB, PHP peak=136 MB.

After installing:
Page execution time was 329.83 ms. Memory used at: devel_boot()=3.86 MB, devel_shutdown()=43.62 MB, PHP peak=48.5 MB.

Oh yeah baby!

Kudos!

damienmckenna’s picture

Issue summary: View changes
Status: Active » Closed (duplicate)

One way of fixing this might be to use the '#dialog' => TRUE option when loading token_tree, e.g.:

(from #1784874: Token dialog for Pathauto)

    $form[$module]['token_help']['help'] = array(
      '#theme' => 'token_tree',
      '#token_types' => array($settings->token_type),
      '#dialog' => TRUE,
    );

The best long term solution will be #1334456: Enable ajax on-demand loading of sub-trees in the Token help. Or fixing the entire contrib realm so that Entity Token isn't used. But I digress.

Until then, I'm marking this as a duplicate of #1334456: Enable ajax on-demand loading of sub-trees in the Token help.

r2coder’s picture

I am also receiving this error - and reported it here: https://www.drupal.org/node/1282422. Anyone know whether or not #13 fix works.

jaspm2004’s picture

nigelheinsius: wow man! thanks! i was dealing with this issue since forever...big thanks!

#5 did it for me, i set maximun depth = 2