Details
Description
With the DocumentStore query API, large result sets can happen; and these are returned as List<Document>, potentially causing large amounts of memory to be allocated.
In the current implementation, the result list is generated based on a list of internal row presentations (RDBRow). These are currently freed when the method finishes. They should be freed as early as possible.
Furthermore, when the result set gets big, RDBDocumentStore should log an error containing the call chain, so that the component doing the excessive query can be identified (it should use paging instead).
(For completeness: we could also change the code to lazily populate the list; but that would be a bigger change)