memory_used_pct()
Return the percentage of script memory still available. Useful as a safety valve in a long loop that builds up a lot of data.
Syntax
memory_used_pct()
Parameters
None.
Returns
A number — the percentage of memory remaining (100 = none used).
Example
foreach ( $bigList as $row ) {
// ... process row ...
if ( memory_used_pct() < 10 ) {
sys_log("Low on memory, stopping early");
break;
}
}
Example output
87.4
Notes
- A niche helper for very large batch operations — most flows never need it.
See also: sys_log()