Reduce CPU load caused by collect_garbage logic running more often than needed

Added additional logic to ensure that only one thread at a time enters the collection logic while also avoiding lock contention on other threads.
Added logic to allow collect_garbage logic to execute at most once a minute.