Scans the global environment for memory-intensive objects and interactively prompts the user to remove them to free up system RAM.
Value
Invisibly returns a named list with components: status ("done",
"clean", or "cancelled"), threshold_mb (numeric), and
objects_removed (character vector of removed object names).
Details
The function implements a simple memory management workflow:
Prompts the user to define a size threshold (in MB) for flagging objects.
Calculates the size of all objects currently residing in the global environment.
Identifies and sorts objects that exceed the specified threshold.
Presents a selection menu allowing the user to choose one or more large objects for removal.
Executes `rm()` on the selected objects and immediately calls `gc()` to ensure the memory is released back to the system.
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()) {
sweep_memory()
}
