Fatal error: Allowed memory size of 94371840 bytes exhausted (tried to allocate 25477409 bytes) in [mysite.com]/sites/all/modules/backup_migrate/includes/destinations.email.inc on line 99

I first tried to run the backup without installing any of the PEAR/TAR stuff and it failed. Then I put the necessary files in the includes directory. Then I tried again and I got the above error. This is on shared hosting, so I could see why this might happen except that the Backup Files module works fine on the site. So it seems like this should be able to work, right?

Comments

ronan’s picture

Does it work when you try to download the file or save it to disk?

Seems like the problem is the way the backup emailing code works. It loads the entire file into memory to encode and attach to the email being sent and this is what is failing with large files. The rest of the module is very careful to not load the backup file into memory all at once to avoid this but I'm not sure if there's any way around doing this for the email destination since the php 'mail' function takes it's message body as a string in memory.

Short of rewriting the module to use something other than the mail function (which doesn't sound like fun at all) the only thing I can do is check file size before loading it into memory so that the module at least dies gracefully. Any file larger than 10MB will probably be rejected by most MTAs anyway so I will probably put a hard limit on how large a file Backup and Migrate is willing to attempt to send.

The bad news is this won't fix your issue, but without being able to simply give the php process more memory, I'm not sure that there is a solution to your issue.

Sorry about that.

butler360’s picture

Yes, it does work when backing up to a download (haven't tried backing up to disk).

If that's just the way it is with email backup, then I'm ok with that. The other module doesn't do that, either, anyways.

Gmail will accept up to 25MB, though, so I suppose people with enough memory could do such a backup.

ronan’s picture

Status: Active » Fixed

Yeah, after a little research I found that gmail will take 25mb but more traditional ISPs limit it somewhere in the 10mb range. I set the B&M limit to 20MB to leave room for base64 encoding etc. It's also overridable in the settings.php for people who want to push the limits of their email provider.

I'm going to mark this fixed because I think that preempting the fatal error with a size check is about the only thing I can do given the limitations of email and the php mail function itself.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.