Ernest Friedman-Hill wrote:Are you sure they are CopyOnWriteArrayList objects, or are they really something like "CopyOnWriteArrayList$1" objects? Each time you call iterator(), a new object is created, and that object is likely to be an anonymous inner class of CopyOnWriteArrayList. Such classes have names like CopyOnWriteArrayList$1, and if you're not paying attention, it's easy to mistake one for the other. So my guess is that the 12,000 objects are really the Iterators you're creating.
That is correct. On the Sun JDK you can find a reference to the inner class COWIterator which takes a reference to each element that is to be iterated.