[
https://issues.apache.org/jira/browse/GROOVY-5936?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15405738#comment-15405738
]
Paul King commented on GROOVY-5936:
-----------------------------------
Just to clarify, the remaining DGM methods on Iterator which call toList are:
{code}
Iterator<T> unique(Iterator<T> self)
Iterator<T> unique(Iterator<T> self, @ClosureParams(value=FromString.class,
options={"T","T,T"}) Closure closure)
Iterator<T> unique(Iterator<T> self, Comparator<T> comparator)
Iterator<T> sort(Iterator<T> self)
Iterator<T> sort(Iterator<T> self, Comparator<T> comparator)
Iterator<T> sort(Iterator<T> self, @ClosureParams(value=FromString.class,
options={"T","T,T"}) Closure closure)
Iterator<T> toSorted(Iterator<T> self, Comparator<T> comparator)
Iterator<T> dropRight(Iterator<T> self, int num)
{code}
Of these, {{sort}} and {{toSorted}} aren't likely to gain us much. The
{{dropRight}} method will have only minor gains. The {{unique}} methods should
be relatively easy though we already have Iterator specific {{toUnique}}
methods.
> java.lang.OutOfMemoryError through Iterator.collectEntries and others (part
> 2: handle others)
> ---------------------------------------------------------------------------------------------
>
> Key: GROOVY-5936
> URL: https://issues.apache.org/jira/browse/GROOVY-5936
> Project: Groovy
> Issue Type: Bug
> Components: groovy-jdk
> Affects Versions: 2.0.4
> Reporter: Alexander Veit
>
> DGM.collectEntries(Iterator, ...) naively calls toList(Iterator<T> self) to
> convert the Iterator to a list. There's no need to do this since iterator
> suffices to collect the entries. Even worse, toList uses ArrayList what may
> lead to multiple reallocations when the ArrayList's capacity must be enlarged.
> Error:
> Caught: java.lang.OutOfMemoryError: GC overhead limit exceeded
> The same problems may occur when calling other methods that internally
> convert Iterator to lists.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)