The short circuiting renormalizer used with ML anomaly detection will skip renormalizations if a more recent set of quantiles has been received.  It does this by maintaining a queue of quantiles documents, but when it is ready to perform the next renormalization it drains the entire queue so that it is left with the most recent.  When quantiles documents are large this is an inefficient use of memory.  Instead of storing the full quantiles documents in a queue it should just retain the most recently added quantiles document.
x-pack/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/job/process/autodetect/output/AutodetectResultProcessorTests.java
processorUnderTest.setDeleteInterimRequired(false);
        Annotation annotation = new Annotation.Builder().setType(Annotation.Type.ANNOTATION)
            .setJobId(JOB_ID)
            .setAnnotation("Categorization status changed to 'warn' for partition 'foo'")
            .setEvent(Annotation.Event.CATEGORIZATION_STATUS_CHANGE)
            .setCreateTime(new Date())
            .setCreateUsername(XPackUser.NAME)
            .setTimestamp(new Date())
            .setPartitionFieldName("part")
            .setPartitionFieldValue("foo")
            .build();
        when(result.getAnnotation()).thenReturn(annotation);
        processorUnderTest.processResult(result);
        verify(persister).bulkPersisterBuilder(eq(JOB_ID));
        verify(bulkAnnotationsPersister).persistAnnotation(annotation);
        verify(auditor).warning(JOB_ID, "Categorization status changed to 'warn' for partition 'foo' after 0 buckets");
    }
    public void testProcessResult_modelSnapshot() {
        AutodetectResult result = mock(AutodetectResult.class);
        ModelSnapshot modelSnapshot = new ModelSnapshot.Builder(JOB_ID).setSnapshotId("a_snapshot_id")
            .setLatestResultTimeStamp(Date.from(Instant.ofEpochMilli(1000_000_000)))
            .setTimestamp(Date.from(Instant.ofEpochMilli(2000_000_000)))
            .setMinVersion(Version.CURRENT)
            .build();
        when(result.getModelSnapshot()).thenReturn(modelSnapshot);
        IndexResponse indexResponse = new IndexResponse(new ShardId("ml", "uid", 0), "1", 0L, 0L, 0L, true);
        when(persister.persistModelSnapshot(any(), any(), any())).thenReturn(
            new BulkResponse(new BulkItemResponse[] { BulkItemResponse.success(0, DocWriteRequest.OpType.INDEX, indexResponse) }, 0)
        );
        processorUnderTest.setDeleteInterimRequired(false);