PHP Classes
elePHPant
Icontem

PHP Memory Limit Manager: Set the PHP memory limit and check if is exceeded

Recommend this page to a friend!

  Author Author  
Name: nvb <contact>
Classes: 9 packages by
Country: Germany Germany
Innovation award
Innovation award
Nominee: 4x


  Detailed description   Download Download .zip .tar.gz  
This package can be used to set the PHP memory limit and check if is exceeded.

It can dynamically set the current PHP script memory usage limit by taking a limit value as parameter in KB, MB and GB.

The package can also set the size of limit buffer, so it can check if the current script memory usage tell the current application that it has reached a given limit that is the current hard memory limit minus that buffer size.

Details

Memory Limit Manager Component for PHP

This free as in freedom component helps you to validate if your script reaches the allowed maximum memory limit.

Furthermore, you can set your own memory limit (as long as it is below the limit in you php.ini).

The build status of the current master branch is tracked by Travis CI: build status Latest stable

The scrutinizer status are: code quality

The versioneye status is: dependencies

Downloads: Downloads this Month

It is also available at openhub.net.

Benefits

  • provides easy setting of memory limit
  • gives you the advantage to add a buffer before reaching the limit to easy up reacting when limit is reached
  • helps you to set the limit in bytes, kilo bytes, mega bytes or giga bytes (same for the buffer)
  • comes with DependentInterface and AwareInterface

Examples

Install

By Hand

mkdir -p vendor/net_bazzline/php_component_memory_limit_manager
cd vendor/net_bazzline/php_component_memory_limit_manager
git clone https://github.com/bazzline/php_component_memory_limit_manager

With Packagist

composer require net_bazzline/php_component_memory_limit_manager:dev-master

Usage

$manager = new Net\Bazzline\Component\MemoryLimitManager\MemoryLimitManager();
$manager->setBufferInMegaBytes(4);
$manager->setLimitInMegaBytes(64);

while (!empty($dataSet)) {
    if ($manager->isLimitReached()) {
        //exit while loop, shutdown process
    } else {
        $data = array_shift($dataSet);
        //work on data set
    }
}

API

Thanks to apigen, the api is available in the document section or online.

History

  • upcomming * @todo * implement way of measure/calculate the amount of memory for next iteration
  • 1.1.0 - released at 27.02.2016 * added dedicated travis integration test for php 7.0 * moved to psr-4 autoloading * removed code coverage * removed dead link * removed dependency to phpmd * updated dependencies
  • 1.0.9 - released at 11.12.2015 * updated dependencies
  • 1.0.8 - released at 18.11.2015 * updated dependencies
  • 1.0.7 - released at 27.08.2015 * updated dependencies
  • 1.0.6 - released at 04.07.2015 * updated dependencies
  • 1.0.5 - released at 22.05.2015 * updated dependencies
  • 1.0.4 - released at 02.08.2015 * updated dependencies * removed dependency to apigen
  • 1.0.3 - released at 31.08.2014 * fixed broken composer.json
  • 1.0.2 - released at 31.08.2014 * added versioneye * added scrutinizer * fixed small bugs * updated dependencies
  • 1.0.1 - released at 27.07.2014 * added missing DependentInterface and AwareInterface
  • 1.0.0 - released at 27.07.2014 * initial commit with examples, unit tests and api documentation

Future Improvements

  • if you have one, create a feature request, fork it (and push it back :-))

  Classes of nvb  >  PHP Memory Limit Manager  >  Download Download .zip .tar.gz  >  Support forum Support forum  >  Blog Blog  >  RSS 1.0 feed RSS 2.0 feed Latest changes  

 

Name: PHP Memory Limit Manager
Base name: php_component_memory
Description: Set the PHP memory limit and check if is exceeded
Version: -
PHP version: 5
License: GNU Lesser General Public License (LGPL)
 
  Groups   Applications   Files Files  

  Groups  
Group folder image PHP 5 Classes using PHP 5 specific features View top rated classes
Group folder image System information Information about servers, processes and operating system facilities View top rated classes
Group folder image Hardware Communicate with computer hardware and peripheral devices View top rated classes


  Applications that use this package  
No pages of applications that use this class were specified.

Add link image If you know an application of this package, send a message to the author to add a link here.

  Files folder image Files  
File Role Description
Files folder imagedocument (15 files, 1 directory)
Files folder imageexample (2 files)
Files folder imagesource (4 files)
Files folder imagetest (2 files)
Accessible without login Plain text file .scrutinizer.yml Data Auxiliary data
Accessible without login Plain text file .travis.yml Data Auxiliary data
Accessible without login Plain text file composer.json Data Auxiliary data
Accessible without login Plain text file generate_api Data Auxiliary data
Accessible without login Plain text file LICENSE Lic. License text
Accessible without login Plain text file phpunit.xml.dist Data Auxiliary data
Accessible without login Plain text file README.md Doc. Documentation

  Files folder image Files  /  document  
File Role Description
Files folder imageresources (11 files)
  Accessible without login HTML file 404.html Doc. Documentation
  Accessible without login HTML file class-Net.Bazzline...umentException.html Doc. Documentation
  Accessible without login HTML file class-Net.Bazzline...ryLimitManager.html Doc. Documentation
  Accessible without login HTML file class-Net.Bazzline...AwareInterface.html Doc. Documentation
  Accessible without login HTML file class-Net.Bazzline...ndentInterface.html Doc. Documentation
  Accessible without login Plain text file elementlist.js Data Auxiliary data
  Accessible without login HTML file index.html Doc. Documentation
  Accessible without login HTML file namespace-Net.Bazzline.Component.html Doc. Documentation
  Accessible without login HTML file namespace-Net.Bazz...ryLimitManager.html Doc. Documentation
  Accessible without login HTML file namespace-Net.Bazzline.html Doc. Documentation
  Accessible without login HTML file namespace-Net.html Doc. Documentation
  Accessible without login HTML file source-class-Net.B...umentException.html Doc. Documentation
  Accessible without login HTML file source-class-Net.B...ryLimitManager.html Doc. Documentation
  Accessible without login HTML file source-class-Net.B...AwareInterface.html Doc. Documentation
  Accessible without login HTML file source-class-Net.B...ndentInterface.html Doc. Documentation

  Files folder image Files  /  document  /  resources  
File Role Description
  Accessible without login Image file collapsed.png Icon Icon image
  Accessible without login Plain text file combined.js Data Auxiliary data
  Accessible without login Image file footer.png Data Auxiliary data
  Accessible without login Image file inherit.png Icon Icon image
  Accessible without login Image file resize.png Icon Icon image
  Accessible without login Image file sort.png Icon Icon image
  Accessible without login Plain text file style.css Data Auxiliary data
  Accessible without login Image file tree-cleaner.png Icon Icon image
  Accessible without login Image file tree-hasnext.png Icon Icon image
  Accessible without login Image file tree-last.png Data Auxiliary data
  Accessible without login Image file tree-vertical.png Icon Icon image

  Files folder image Files  /  example  
File Role Description
  Accessible without login Plain text file withoutReachingLimit.php Example Example script
  Accessible without login Plain text file withReachingLimit.php Example Example script

  Files folder image Files  /  source  
File Role Description
  Plain text file InvalidArgumentException.php Class Class source
  Plain text file MemoryLimitManager.php Class Class source
  Plain text file MemoryLimitManagerAwareInterface.php Class Class source
  Plain text file MemoryLimitManagerDependentInterface.php Class Class source

  Files folder image Files  /  test  
File Role Description
  Accessible without login Plain text file bootstrap.php Aux. Auxiliary script
  Plain text file MemoryLimitManagerTest.php Class Class source

Download Download all files: php_component_memory.tar.gz php_component_memory.zip
NOTICE: if you are using a download manager program like 'GetRight', please Login before trying to download this archive.