Skip to content

Commit

Permalink
Watch for memory problems
Browse files Browse the repository at this point in the history
  • Loading branch information
GlazerMann authored Jan 27, 2024
1 parent 413a28c commit 8ea2d1f
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions expandFns.php
Original file line number Diff line number Diff line change
Expand Up @@ -958,6 +958,17 @@ function throttle () : void {
$min_interval = 2 * $cycles; // How many seconds we want per-write on average
if ($last_write_time === 0) $last_write_time = time();

$mem_max = (string) @ini_get('memory_limit');
if (preg_match('~^(\d+)M$~', $mem_max, $matches)) {
$mem_used = memory_get_usage() / (1024*1024);
$mem_max = (@int_val($matches[1])) * 0.9;

Check failure on line 964 in expandFns.php

View workflow job for this annotation

GitHub Actions / build

Function int_val not found.
if ($mem_max !== 0 && ($mem_used > $mem_max)) {
@clearstatcache();
@strtok('','');
HandleCache::free_memory();
AdsAbsControl::free_memory();
}
}
$phase = $phase + 1;
if ($phase < $cycles) {
return;
Expand Down

0 comments on commit 8ea2d1f

Please sign in to comment.