On 11/6/07, Stefano Bagnara <[EMAIL PROTECTED]> wrote: > > Robert Burrell Donkin ha scritto: > > https://issues.apache.org/jira/browse/JAMES-734 discusses the general > > design of the API > > > > one major issue for IMAP ATM is that when FETCHing a large quantity of > > data, all that data has to be loaded into memory and then the full > > result created in a StringBuffer before the output begins. this uses a > > lot of memory. > > > > there are different ways to approach this issue. IMHO using arrays, > > lists or iterators is as much a matter of style than substance. > > > > one approach would be to use result objects which are lazily > > populated. this would be reasonably easy for Torque. this would also > > mean either adding a close() operation or making the content objects > > read-once allowing the result to recycle the memory. > > It seems Iterator is the right interface for this scenario. > Once you call next() the previous result is unrefereced. > Using iterator we don't need close() because they are already > "read-once", right?
close would be beneficial, if you dont want to iterate over the result, only to get, for example the first result, and you want to ensure, that the allocated resources are released correcltly. Of course the implementation of this iterator calls the close method after the final element returned automaticaly. Arrays are not an option because we cannot encapsulate an array so we > cannot lazyload it. > > Do we need to know the size() at the beginning or we can just loop while > there are new results? If we need the size Iterator is not enough and we > probably need a List, otherwise I would go with Iterator. +1 Zsombor
