English 中文(简体)
php background job cause exception on memory_limit
原标题:

if i have a php background job, may need to run 4-5hours or more will it cause exception on memory_limit

最佳回答

PHP has a very primitive memory manager and scripts are not designed to run for very long. You can update the memory limit like this:

<?php ini_set(“memory_limit”,”256M”); ?>

But you will probably still have memory problems. You could try adding a ton of unset() s to your script and this can help a bit. But the memory leaks are probably in PHP and its C/C++ extensions which you can t control. In the past I have had to rewrite background tasks in Java.

问题回答

In your php.ini increase the amount for memory_limit.

See http://www.ducea.com/2008/02/14/increase-php-memory-limit/

Check out the following PHP commands:

// Sets the max time in seconds the script can run
set_time_limit($sec);
// Increases the memory limit (default is 1.5mb)
ini_set("memory_limit", "256M");




相关问题
Brute-force/DoS prevention in PHP [closed]

I am trying to write a script to prevent brute-force login attempts in a website I m building. The logic goes something like this: User sends login information. Check if username and password is ...

please can anyone check this while loop and if condition

<?php $con=mysql_connect("localhost","mts","mts"); if(!con) { die( unable to connect . mysql_error()); } mysql_select_db("mts",$con); /* date_default_timezone_set ("Asia/Calcutta"); $date = ...

定值美元

如何确认来自正确来源的数字。

Generating a drop down list of timezones with PHP

Most sites need some way to show the dates on the site in the users preferred timezone. Below are two lists that I found and then one method using the built in PHP DateTime class in PHP 5. I need ...

Text as watermarking in PHP

I want to create text as a watermark for an image. the water mark should have the following properties front: Impact color: white opacity: 31% Font style: regular, bold Bevel and Emboss size: 30 ...

How does php cast boolean variables?

How does php cast boolean variables? I was trying to save a boolean value to an array: $result["Users"]["is_login"] = true; but when I use debug the is_login value is blank. and when I do ...

热门标签