ingelabs / classpath

GNU Classpath, Essential Libraries for Java
Other
8 stars 3 forks source link

DecimalFormat: Fix memory leak #35

Closed guillerodriguez closed 3 months ago

guillerodriguez commented 3 months ago

DecimalFormat keeps a list of FieldPosition attributes for use by formatToCharacterIterator(). However, all format() methods add attributes to this list, even if they are not needed. Also, the list is only cleared by formatToCharacterIterator() (which might not be called at all).

Fix this by only recording attribute information when required, and clearing the list immediately after use.

Fixes #28 (BZ#30977)