elasticsearch/elasticsearch — pull request #8138 by mfussenegger (2014-10-17 13:14:33+00:00)
Title: reduce memory usage during fetch source sub phase

If includes or excludes are set
XContentFactory.xcontentBuilder() allocates a new
BytesStreamOutput using the default page size which is 16kb.

Can be optimized to use the length of the sourceRef because
that is the maximum possible size that the streamOutput will
use.

This redcues the amount of memory allocated for a request
that is fetching 200.000 small documents (~150 bytes each)
by about 300 MB