memory_limit is truncating ZipCart downloads (not zip creation!)

filip_tc

Joined: 2006-05-25
Posts: 29
Posted: Wed, 2009-11-11 22:47


Gallery version (not just "2"): 2.3 core 1.3.0 (svn)
PHP version (e.g. 5.1.6): 5.2.9 apache2handler
PHPInfo Link (see FAQ): http://ftc.3pas.org/phpinfo_rnd_37jfg2fe.php
Webserver (e.g. Apache 1.3.33): Apache 2.2.13
Database (e.g. MySql 5.0.32): mysqli 5.0.81-community, lock.system=flock
Activated toolkits (e.g. NetPbm, GD):Exif, LinkItemToolkit, Thumbnail, Gd, ArchiveUpload, ImageMagick, Dcraw, jpegtran
Operating system (e.g. Linux): Unix
Browser (e.g. Firefox 2.0): irrelevant / FFox3.5

When using the ZipCart to generate and download a ~500Mb zip archive (which displays with its correct file size in the browser), it starts downloading fine but always finishes at 95.4Mb. The resulting zip is corrupted (/incomplete). Any chance this is ZipCart's fault? If not, is it a server-limit fault? (Which limit?)

Login or register to post comments
filip_tc

Joined: 2006-05-25
Posts: 29
Posted: Wed, 2009-11-11 22:52

I just came to the conclusion that:
100000000 bytes = ~95.4 megabytes (95,38MB)
so it would seem like a really big coincidence for it to not be a limit issue... But which limit?? The guys from my hostings didn't seem to know about any limit (or at least so they claimed).

Login or register to post comments
filip_tc

Joined: 2006-05-25
Posts: 29
Posted: Wed, 2009-11-11 23:00

I uploaded a 150Mb file to my server just to check and it downloads fine... I'm confused....

Login or register to post comments
filip_tc

Joined: 2006-05-25
Posts: 29
Posted: Fri, 2009-11-13 01:08

So, I found some interesting new info. My hosting team said the following:

"If a php script is handling the download itself through the gallery2 software it would be terminated by a php's 'max_execution_time' of 30s. This may be why you can download it directly from the server, but not through the image gallery software."

Please correct me if I'm getting ahead of myself but, obviously, some kind of script must be dealing with the zip file, since it's being generated outside of the public www folder and yet somehow being re-piped to the user via http. And that script must be executing throughout the entire download for the file's integrity's sake. So the big question is (if I am on the right path):

Can this behavior be avoided / worked around?

Login or register to post comments
filip_tc

Joined: 2006-05-25
Posts: 29
Posted: Fri, 2009-11-13 02:49

Ignore my last message. I was wrong.
Why not look at the apache logs? I did and check this:

Quote:
[11-nov-2009 07:32:37] PHP Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 100147201 bytes) in .../gallery2/modules/zipcart/Download.inc on line 89

Ok, is there a way around that?

Login or register to post comments
suprsidr
suprsidr's picture

Joined: 2005-04-17
Posts: 3113
Posted: Fri, 2009-11-13 03:21

Have your host allow more memory.
In this day and age memory/bandwidth/storage are cheap.
you can also try adding:

@ini_set('memory_limit', '48M');

to gallery2/config.php just after @ini_set('display_errors', 0);
if your host allows such things, you can extend execution time the same way.

-s
FlashYourWeb and Your Gallery with The E2 XML Media Player for Gallery2

Login or register to post comments
filip_tc

Joined: 2006-05-25
Posts: 29
Posted: Fri, 2009-11-13 13:30

The limit is already at 128M and hosting doesn't allow ini_set changes...

Login or register to post comments
suprsidr
suprsidr's picture

Joined: 2005-04-17
Posts: 3113
Posted: Fri, 2009-11-13 13:38
Quote:
Ok, is there a way around that?

Smaller zips, or more memory.
134217728 bytes is 128MB

-s
FlashYourWeb and Your Gallery with The E2 XML Media Player for Gallery2

Login or register to post comments
nivekiam
nivekiam's picture

Joined: 2002-12-10
Posts: 10934
Posted: Fri, 2009-11-13 17:51

If you want PHP to create or deal with a 512MB zip file you're going to need to allow AT LEAST 512MB of memory for PHP.

I think, suprsidr can correct me if needed, the deal is that the zip file may in fact be getting created, however, ALL file downloads (your images, zips, etc) are run through Gallery and it's not a direct download. But instead goes through Gallery's "image firewall" and is served up by PHP and not a direct file link to download from your web server (who wouldn't care what size the file is unless your host has some asinine restrictive module installed for the web server)

It would either take more investigating or someone who knows to figure out exactly where, but either way as suprsidr stated you need more memory to deal with large files.
____________________________________________
Like Gallery? Like the support? Donate now!!! See G2 live here

Login or register to post comments
filip_tc

Joined: 2006-05-25
Posts: 29
Posted: Fri, 2009-11-13 18:02
nivekiam wrote:
the deal is that the zip file may in fact be getting created, however, ALL file downloads (your images, zips, etc) are run through Gallery and it's not a direct download. But instead goes through Gallery's "image firewall" and is served up by PHP and not a direct file link to download from your web server (who wouldn't care what size the file is unless your host has some asinine restrictive module installed for the web server)

I think that's exactly the problem. But I guess I'm stuck for now because limits on this host (and my current hosting plan) are pretty static...

Login or register to post comments