United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
Bug ID: JDK-4963875 RFE: Reduction of space used by instances of java.util.BitSet
JDK-4963875 : RFE: Reduction of space used by instances of java.util.BitSet

Details
Type:
Enhancement
Submit Date:
2003-12-04
Status:
Resolved
Updated Date:
2005-03-19
Project Name:
JDK
Resolved Date:
2005-03-19
Component:
core-libs
OS:
linux
Sub-Component:
java.util
CPU:
x86
Priority:
P4
Resolution:
Fixed
Affected Versions:
1.4.2
Fixed Versions:

Related Reports
Relates:

Sub Tasks

Description

Name: rmT116609			Date: 12/04/2003


A DESCRIPTION OF THE REQUEST :
Line 985 in file BitSet.java (method clone()) is:

>>>
        result.bits = new long[bits.length];
<<<

It should be changed to:

>>>
        result.bits = new long[unitsInUse];
<<<


JUSTIFICATION :
It is not necessary to allocate more space than required. In the current
version, the unused space is never de-allocated.
(Incident Review ID: 229199) 
======================================================================

                                    

Comments
EVALUATION

Sounds reasonable as long as it is acceptable that a cloned BitSet could have a different size() value than the one it was cloned from. Unfortunately for historical reasons size() returns the actual storage space rather than the logical size of a BitSet. This could be a compatibility issue.
###@###.### 2003-12-04

It is a bug in the original spec that size() was exposed, and a further
bug that clone() was spec'ed to return a BitSet of the same size as its
evil twin.  It's hard for me to imagine someone depending on
s.size() == s.clone().size()
but who knows?

It's also a good idea to shrink our BitSets occasionally automatically,
as well as to provide an explicit trimToSize().
###@###.### 2005-1-27 02:58:03 GMT
                                     
2005-01-27



Hardware and Software, Engineered to Work Together