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/slm/src/main/java/org/elasticsearch/xpack/slm/SnapshotRetentionTask.java
allDeletesListener.onFailure(e);
                    }
                }), () -> {
                    runningDeletions.remove(snapshotId);
                    long finishTime = nowNanoSupplier.getAsLong();
                    TimeValue deletionTime = TimeValue.timeValueNanos(finishTime - deleteStartTime);
                    logger.debug("elapsed time for deletion of [{}] snapshot: {}", snapshotId, deletionTime);
                }));
                success = true;
            } catch (Exception e) {
                listener.onFailure(e);
            } finally {
                if (success == false) {
                    runningDeletions.remove(snapshotId);
                }
            }
        }
    }
    /**
     * Delete the given snapshot from the repository in blocking manner
     *
     * @param repo     The repository the snapshot is in
     * @param snapshot The snapshot metadata
     * @param listener {@link ActionListener#onResponse(Object)} is called if a {@link SnapshotHistoryItem} can be created representing a
     *                  successful or failed deletion call. {@link ActionListener#onFailure(Exception)} is called only if interrupted.
     */
    void deleteSnapshot(
        String slmPolicy,
        String repo,
        SnapshotId snapshot,