The SLM retention clean up task `SnapshotRetentionTask` lists all snapshots in order to identify the snapshots to retain and the snapshots to delete. While doing so it retrieves the full snapshot information, including shard snapshot details and shard snapshot failures, to later  only use snapshot metadata and snapshot timestamp to select the snapshots to retain. When the snapshots contain thousands of shards it represents of lot of objects that are unnecessary created, putting a lot of pressure on the garbage collector.

We should improve the way SLM retrieves snapshots to reduce the huge allocations of objects. David made some [interesting](https://github.com/elastic/elasticsearch/issues/99953#issuecomment-1738534389) [suggestions](https://github.com/elastic/elasticsearch/issues/99953#issuecomment-1738626743) in comments.

- #100044
- #100053
- #100054
- #100058
- #100065
- #100070
- #100092
x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/slm/SnapshotRetentionConfiguration.java
} else if (UNSUCCESSFUL_STATES.contains(si.state())) {
                        maybeEligible = sortedSnapshots.contains(si);
                    } else {
                        logger.trace("[{}] INELIGIBLE because snapshot is in state [{}]", snapName, si.state());
                        return false;
                    }
                    if (maybeEligible == false) {
                        
                        
                        logger.trace(
                            "[{}]: INELIGIBLE as snapshot expiration would pass the "
                                + "minimum number of configured snapshots ({}) to keep, regardless of age",
                            snapName,
                            this.minimumSnapshotCount
                        );
                        return false;
                    }
                }
                final long snapshotAge = nowSupplier.getAsLong() - si.startTime();
                if (snapshotAge > this.expireAfter.getMillis()) {
                    logger.trace(
                        () -> format(
                            "[%s]: ELIGIBLE as snapshot age of %s is older than %s",
                            snapName,
                            new TimeValue(snapshotAge).toHumanReadableString(3),
                            this.expireAfter.toHumanReadableString(3)
                        )
                    );
                    return true;
                } else {