private void tryReleaseOldImage(MetadataImage oldImage, MetadataImage newImage) {
        // Expect the old image is already replaced by the new image.
        // If there is any reference to the old image, it should invoke the #retain and release after used.
        if (oldImage != null && newImage.objectsMetadata() != oldImage.objectsMetadata()) {
            oldImage.objectsMetadata().release();
        }
        if (oldImage != null && newImage.streamsMetadata() != oldImage.streamsMetadata()) {
            oldImage.streamsMetadata().release();
        }
    }
Callback used by MetadataBatchLoader and handleLoadSnapshot to update the active metadata publishers.
metadata/src/main/java/org/apache/kafka/image/loader/MetadataLoader.java