www.webdeveloper.com
Results 1 to 2 of 2

Thread: Fatal error: Out of memory even though memory_limit set to -1

  1. #1
    Join Date
    Apr 2012
    Posts
    19

    Fatal error: Out of memory even though memory_limit set to -1

    Hello fellow developers,

    I've written a php script that scans through LOADS of folders and files and generates a word document with tables that list files and folders if they match certain criteria. I am running the script via command line on a Windows box.

    I have set the memory_limit parameter in php.ini to -1 AND I have hard coded ini_set('memory_limit', '-1') into the script so that there is no possible way for PHP to run out of memory (right?).

    However, I am still getting the following error:

    Fatal error: Out of memory (allocated X) (tried to allocated Y bytes) in file...

    I'm starting to suspect that the problem is occurring because windows is not allocating enough RAM to PHP. To find out how much memory the server has and how much is being allocated to PHP from windows, I added the following lines of code to my script:

    PHP Code:
    //output total RAM for the windows box
    exec('wmic memorychip get capacity'$totalMemory);
    echo 
    array_sum($totalMemory);
    //output = 4294967296 (4GB)

    //memory allocated to PHP from windows
    echo memory_get_usage();
    //output = 384848 (approx. 376KB) 
    Is the reason why I am still getting the "Out of memory" error because windows is not allowing PHP enough RAM? If so, does anyone know how to increase the memory that PHP is allowed to use?

    Please help and thank you!!!

    Chris

  2. #2
    Join Date
    Aug 2004
    Location
    Ankh-Morpork
    Posts
    19,326
    I'm not enough of a Windows OS guru (if at all?) to know what might need to be tweaked for it, but have you tried something like the following to find out what your script really thinks is the memory limit at run-time?
    PHP Code:
    error_log("Current memory limit: ".ini_get('memory_limit')); 
    (Just in case it points to something maybe overriding (or denying) your setting of the memory limit.)
    "Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be."
    ~ Terry Pratchett in Nation

    eBookworm.us

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles