Hunts down "invisible" memory hogs such as massive temporary files, unclosed graphical devices, and uncollected garbage, prompting the user for targeted cleaning to reclaim system resources.
Value
Invisibly returns a named list with components: status ("done" or
"cancelled"), actions_taken (character vector),
temp_flushed_mb (numeric), and devices_closed (integer).
Details
The function performs a system scan for three types of "zombie" data:
Temporary Files: Calculates the total size of the current session's temporary directory. If it exceeds 5 MB, it offers to flush it.
Graphical Devices: Checks for any open graphical devices (e.g., PDF, PNG, or RStudioGD) and offers to close all of them.
Orphaned Memory: Offers to perform a "deep" garbage collection by calling `gc()` twice, which forces R to clear both older and newer generations of memory.
Warning
This function modifies files on disk or the global environment. Please ensure you have a backup or are using version control (e.g., Git) before execution.
Examples
if (interactive()) {
hunt_zombies()
}
