United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
Bug ID: JDK-4546734 Add method StringBuffer.trimToSize
JDK-4546734 : Add method StringBuffer.trimToSize

Details
Type:
Enhancement
Submit Date:
2001-12-05
Status:
Resolved
Updated Date:
2003-05-16
Project Name:
JDK
Resolved Date:
2003-05-16
Component:
core-libs
OS:
windows_nt,solaris_7,generic
Sub-Component:
java.lang
CPU:
x86,sparc,generic
Priority:
P4
Resolution:
Fixed
Affected Versions:
1.3.0,1.4.0,1.4.1
Fixed Versions:
5.0 (tiger)

Related Reports
Duplicate:
Duplicate:
Relates:
Relates:

Sub Tasks

Description
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.

                                    

Comments
EVALUATION

Can be done in Tiger.
###@###.### 2001-12-04

The name trimToSize might be better.
###@###.### 2002-02-14
                                     
2001-12-04
CONVERTED DATA

BugTraq+ Release Management Values

COMMIT TO FIX:
tiger

FIXED IN:
tiger

INTEGRATED IN:
tiger
tiger-b07


                                     
2004-06-14



Hardware and Software, Engineered to Work Together