JDK-4546734 : Add method StringBuffer.trimToSize
  • Type: Enhancement
  • Component: core-libs
  • Sub-Component: java.lang
  • Affected Version: 1.3.0,1.4.0,1.4.1
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • OS: generic,solaris_7,windows_nt
  • CPU: generic,x86,sparc
  • Submitted: 2001-12-05
  • Updated: 2017-05-16
  • Resolved: 2003-05-16
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
5.0 tigerFixed
Related Reports
Duplicate :  
Duplicate :  
Relates :  
Relates :  
When a StringBuffer is turned into a String, the new String
 uses the StringBuffer's backing array. This is a very fast
way to create the String since no allocation is necessary
but it can waste space since the backing array may be much
larger than the resulting String. Reusing StringBuffers can
make this problem worse since the StringBuffer may have grown
its backing array in past usages.

We would like to give users a method to use if they feel that
the efficient use of memory is more important than the speed that
toString currently has. Adding a compact method in StringBuffer
would allow a user to eliminate the wasted memory by causing the
backing array to be resized to fit the length of the StringBuffer.
The idiom buffer.compact().toString() will result in a String
with a backing array of the minimum size required.

CONVERTED DATA BugTraq+ Release Management Values COMMIT TO FIX: tiger FIXED IN: tiger INTEGRATED IN: tiger tiger-b07

EVALUATION Can be done in Tiger. ###@###.### 2001-12-04 The name trimToSize might be better. ###@###.### 2002-02-14