Advanced search  


cpg1.5.48 Security release - upgrade mandatory!
The Coppermine development team is releasing a security update for Coppermine in order to counter a recently discovered vulnerability. It is important that all users who run version cpg1.5.46 or older update to this latest version as soon as possible.

Pages: [1]   Go Down

Author Topic: Improve memory management  (Read 6951 times)

0 Members and 1 Guest are viewing this topic.


  • Contributor
  • Coppermine frequent poster
  • ***
  • Country: se
  • Offline Offline
  • Posts: 106
  • Coppermine 1.5.22
Improve memory management
« on: January 10, 2013, 01:04:30 am »

When reading this forum default reply message when uploads fail with exhausted memory messages

it's outdated alot saying that memory increase can't be done with ini_set

To increase the memory limit allocation in php.ini, you must be the server's administrator.
Also, .htaccess files cannot change this configuration setting, and it cannot be changed using ini_set().
This being said, most coppermine users who are on shared webhosting will not be able to change this.

PHP Manual says PHP_INI_ALL (Entry can be set anywhere) for memory_limit

I have one of my accounts at which is a very low-cost hosting company in Denmark with currently 1 Million accounts.

I made a test of increasing memory like this

    print '<br>ini_get memory_limit: ' . ini_get('memory_limit');
    ini_set('memory_limit', '128M');
    print '<br>ini_get memory_limit: ' . ini_get('memory_limit');
    print '<br>';
    $x = array();
    for($i = 1; $i > 0; $i++) $x[$i] = 1.0;

with this result

ini_get memory_limit: 80M
ini_get memory_limit: 128M
 Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 20 bytes) in .................

Which proves that I got the 128M being requested instead of host configuration of 80M

Conclusion why don't you ask for more memory in and try to request enough memory to avoid the exhausted message?
Better make the required memory size configurable for the gallery owner
During installation you can also determine if there is an upper limit for memory size increase

Asking users to resize their pictures before upload is not 2013 style


  • Administrator
  • Coppermine addict
  • *****
  • Country: gb
  • Offline Offline
  • Gender: Male
  • Posts: 4885
Re: Improve memory management
« Reply #1 on: January 10, 2013, 08:52:38 am »

I personally think that is not an option. It is up to the webmaster to set suitable limits and also up to the host. We see many hosts that threaten to pull their clients for various reasons and if a script is fiddling with their memory limits in a core file then that gives them more ammunition. This is why we advise on various methods of doing this, methods that the webmaster can control.

The better way IMHO is for us to look at a future upload script that will be a bit more efficient and maybe resize during upload. There are HTML 5 uploaders that do this.
It is a mistake to think you can solve any major problems just with potatoes.


  • Administrator
  • Coppermine addict
  • *****
  • Country: de
  • Offline Offline
  • Gender: Male
  • Posts: 15764
Re: Improve memory management
« Reply #2 on: January 10, 2013, 11:19:15 am »

I share Phill's opinion. It's no option that Coppermine changes the server limits by default. Additionally, not all hosts allow ini_set, which will result in error messages like
Code: [Select]
Warning: ini_set() has been disabled for security reasons(which could of course be suppressed by using @ini_set).

It would be possible to add is as an option to cpg1.6.x, but as people don't read and often set stupid high values it's maybe better to create a plugin for this purpose, so those people don't have any chance to blame Coppermine that their hosts have kicked them. Such a plugin is probably created quite fast and would be also available for cpg1.5.x.

Automatically resizing pictures during upload (according to the gallery settings) would of course be great, but doesn't ensure that there will be sufficient memory to process the uploaded pictures. But I think we should schedule such an uploader for cpg1.6.x.

I think we can avoid some support requests if we combine both the plugin and the new uploader.

Moving to feature requests board.
Pages: [1]   Go Up

Page created in 0.026 seconds with 20 queries.