Montego Scripts: Forums
 

 

View next topic
View previous topic
Post new topic   Reply to topic
Author Message
hicux
Newbie
Newbie



Joined: Jan 30, 2009
Posts: 92
Location: NL

PostPosted: Thu Jul 04, 2013 3:34 am Reply with quote

AH01215: PHP Fatal error: Allowed memory size of 67108864 bytes exhausted (tried to allocate 22937311 bytes) in /www.bestbuildpc.org/includes/csrf-magic.php on line 209,

from csrf-magic.php

Code:
      // not HTML until proven otherwise
      if (stripos($buffer, '<html') !== false) {


Note: I tried to upload VLC Player and when I download it I get 0 bytes. The file was upload it 5 times to be sure it wasn't corrupt. Any clue about this error Montego.

Shocked
 
View user's profile Send private message Visit poster's website
Guardian
Site Admin
Site Admin



Joined: Jul 18, 2005
Posts: 397

PostPosted: Thu Jul 04, 2013 5:52 pm Reply with quote

That is an error due to exceeding the maximum amount of memory allowed by PHP within your particular servers configuration. Sometimes you can increase the servers default value by placing the following code in mainfile.php
Code:

ini_set("memory_limit","12M");

You will need to change '12M' to whatever you need (provided it does not exceed the servers installed memory) however, if you are on a shared server, you will definitely be affecting others using the server.
 
View user's profile Send private message
hicux
Newbie
Newbie



Joined: Jan 30, 2009
Posts: 92
Location: NL

PostPosted: Thu Jul 04, 2013 6:11 pm Reply with quote

Thanks Guardian. I just did it like this and it it working properly

Code:

if (!defined('END_TRANSACTION')) {
   define('END_TRANSACTION', 2);
}

ini_set("memory_limit","256M");


To be sure your code was working. I disable it and I tried to download again and the result was 0 bytes. So I enable it again I got the file. Amazing! Very Happy
 
View user's profile Send private message Visit poster's website
montego
Site Admin/Owner
Site Admin/Owner



Joined: Feb 12, 2005
Posts: 1399

PostPosted: Sat Jul 06, 2013 11:16 am Reply with quote

Where this is occurring is interesting. CSRF Magic has nothing to do with the Downloads module, but there is obviously an inter-dependency. the RN Team may need to also look at this. Thank you for reporting this.

_________________
“To err is human, but when the eraser wears out ahead of the pencil, you’re overdoing it.”
-- Josh Jenkins 
View user's profile Send private message Visit poster's website
hicux
Newbie
Newbie



Joined: Jan 30, 2009
Posts: 92
Location: NL

PostPosted: Mon Sep 02, 2013 7:04 pm Reply with quote

Guys! After doing some more tests I found out if I upload a file of 500MB then I've gotta a blank page so I changed the value for this

Code:

ini_set("memory_limit","2048M");


Note: When I press download it loads for some seconds and then I get the file. Very Happy

I wonder why this is happening? I never got this issue before. Sad

I wonder if we can do this trick from

http://stackoverflow.com/questions/11822294/is-ini-setmemory-limit-512m-too-much

Code:
<?php
    function readfile_chunked ($filename,$type='array') {
      $chunk_array=array();
      $chunksize = 1*(1024*1024); // how many bytes per chunk
      $buffer = '';
      $handle = fopen($filename, 'rb');
      if ($handle === false) {
       return false;
      }
      while (!feof($handle)) {
          switch($type)
          {
              case'array':
              // Returns Lines Array like file()
              $lines[] = fgets($handle, $chunksize);
              break;
              case'string':
              // Returns Lines String like file_get_contents()
              $lines = fread($handle, $chunksize);
              break;
          }
      }
       fclose($handle);
       return $lines;
    }
?>
 
View user's profile Send private message Visit poster's website
Guardian
Site Admin
Site Admin



Joined: Jul 18, 2005
Posts: 397

PostPosted: Tue Sep 03, 2013 2:43 am Reply with quote

I guess you could try it and see if it works for you.
The problem with most servers is there is a limit to the amount of memory you can use and also, PHP itself has a script execution time limit. In uploading a file of that size, I think you would most certainly hit the timer limit, which would cause a blank page because PHP would simply stop executing the file upload.
Chunking the file would certainly help but you might also find the file gets corrupted in some cases when it gets stitched back together.
 
View user's profile Send private message
montego
Site Admin/Owner
Site Admin/Owner



Joined: Feb 12, 2005
Posts: 1399

PostPosted: Tue Sep 03, 2013 9:00 am Reply with quote

I agree with Guardian. Shared hosting plans and PHP are not well suited for high memory and/or long running processes. It is not a limitation of the code itself, but of PHP/host limitations. Just the nature of the "beast".

I have always just used FTP to load up large files and then add the download using the local file patch instead. I know that doesn't help you for user submitted downloads, but what do you expect of the platform?

I think having the ability to store downloads anywhere (web accessible of course), might even be a better option, buy you still have to upload the file using that service's toolset...

_________________
“To err is human, but when the eraser wears out ahead of the pencil, you’re overdoing it.”
-- Josh Jenkins 
View user's profile Send private message Visit poster's website
Display posts from previous:       
Post new topic   Reply to topic

View next topic
View previous topic
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001-2007 phpBB Group
All times are GMT - 4 Hours
 
Forums ©
linear-bunch