I am facing an issue running a job which is sometimes using memory more than expected and now i want to implement a script which failed the execution when memory reaches to 80% or more.
Asked
Active
Viewed 48 times
1
-
Look into using ulimit. – Raman Sailopal Jul 29 '21 at 13:29
1 Answers
0
You can set the memory limit by adding the following line -
ini_set('memory_limit', '256M');
The value is in bytes. The job/script will terminate with an error if the allocated memory is exhausted. More details related to ini_set can be found at - ini_set

Sibi Kandathil
- 126
- 1
- 9
-
thanks, but i need to inform the user before memory exhausted (equal to or more than 80%) and I will show them a custom error. – Harat Jul 29 '21 at 19:31
-
Maybe combining with this answer helps: https://stackoverflow.com/a/27581958/7362396 – Tobias K. Jul 29 '21 at 19:41