Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 353558

Summary: StreamBufferBase allocates 4k buffers even when reading 1 byte sources
Product: [Tools] CDT Reporter: Daniel Thomas <daniel.thomas>
Component: cdt-debug-edcAssignee: Ken Ryall <ken.ryall>
Status: RESOLVED FIXED QA Contact: Ken Ryall <ken.ryall>
Severity: normal    
Priority: P3 CC: cdtdoug, jamesblackburn+eclipse, kirk.beitz
Version: 8.0   
Target Milestone: ---   
Hardware: All   
OS: All   
Whiteboard:
Attachments:
Description Flags
Patch to fix buffer size to smallest power of 2 large enough if 4096 too high cdtdoug: iplog+

Description Daniel Thomas CLA 2011-08-02 06:31:10 EDT
Build Identifier: I20110613-1736

org.eclipse.cdt.debug.edc.internal.StreamBufferBase is an abstract class used by MemoryStreamBuffer among others. It allocates BUFFER_SIZE = 4096 bytes for use as a buffer for reading whatever underlying source that its children are wrapping. However in many cases (particularly for MemoryStreamBuffer) what is being buffered is much smaller than 4096 bytes, for example 1 byte. Hence this behavior results in excessive memory usage.

The patch to fix this more than halves memory consumption under some workloads.

Reproducible: Always

Steps to Reproduce:
1. Analyze something sufficiently well that the whole executable (or close to it) is read in.
2. Use -Xmx368m -XX:+HeapDumpOnOutOfMemoryError or similar to cause a heap dump to occur when it uses lots of memory
3. Use MemoryAnalyzer to analyze where all the memory is going (this may take some time)
Comment 1 Daniel Thomas CLA 2011-08-02 06:32:49 EDT
Created attachment 200697 [details]
Patch to fix buffer size to smallest power of 2 large enough if 4096 too high
Comment 2 Kirk Beitz CLA 2011-08-04 21:18:53 EDT
patch applied and nominally tested locally; awaiting final review and final merge to eclipse edc git repository by ken ryall.