Skip to content

Commit

Permalink
Out of memory crashes - deal with better
Browse files Browse the repository at this point in the history
  • Loading branch information
GlazerMann authored Jan 21, 2024
1 parent 0e8e475 commit ace82e6
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
1 change: 1 addition & 0 deletions big_jobs.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ function big_jobs_name() : string { // NEVER save this string. Always use this f

/** @param resource $lock_file **/
function big_jobs_we_died($lock_file) : void {
HandleCache::free_memory();
@fclose($lock_file);
hard_unlink(big_jobs_name());
}
Expand Down
17 changes: 10 additions & 7 deletions expandFns.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,18 @@ public static function check_memory_use() : void {
2*count(self::$cache_hdl_loc) + // These include a path too
count(self::$cache_hdl_null);
if ($usage > self::MAX_CACHE_SIZE) {
self::$cache_active = [];
self::$cache_inactive = [];
self::$cache_good = [];
self::$cache_hdl_loc = [];
self::$cache_hdl_bad = self::BAD_DOI_ARRAY;
self::$cache_hdl_null = [];
gc_collect_cycles();
self::free_memory();
}
}
public static function free_memory() : void {
self::$cache_active = [];
self::$cache_inactive = [];
self::$cache_good = [];
self::$cache_hdl_loc = [];
self::$cache_hdl_bad = self::BAD_DOI_ARRAY;
self::$cache_hdl_null = [];
gc_collect_cycles();
}
}


Expand Down

0 comments on commit ace82e6

Please sign in to comment.