MergeManagerImpl#close adds the contents of inMemoryMergedMapOutputs and inMemoryMapOutputs to a list of map outputs that is subsequently processed, but it does not clear those sets. This prevents some of the map outputs from being garbage collected and significantly reduces the memory available for the subsequent reduce phase.
This was fixed for trunk and branch-2 by
MAPREDUCE-5493, but that has since been closed after 2.1.1 released. This JIRA tracks backporting the fix to branch-0.23 as well.