hadoop-common-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Kay Kay <kaykay.uni...@gmail.com>
Subject Re: clearing o.a.h.io.Text
Date Fri, 01 Jan 2010 10:39:41 GMT
On Thu, Dec 31, 2009 at 11:03 PM, Owen O'Malley <omalley@apache.org> wrote:

>
> On Dec 30, 2009, at 12:36 AM, Kay Kay wrote:
>
>  In o.a.h.io.Text - the clear method currently just resets length to 0,
>> while not doing anything about the bytes internally.
>>
>> Curious to know the thoughts behind the decision (to let the internal
>> bytes to be reused for future appends  vs. memory leaks due to not clearing
>> them ) ?
>>
>
> The byte array that backs up the Text object is always reused.


I believe that behavior would be surprising to the user if they were
expecting the object resources to be released entirely, by calling the
clear() method.

May be - clear() can reset the internal byte buffer and another method
provided - called reset() / rewind() that can reuse the existing internal
buffer while resetting the length variable only.




> It might make sense to have a setCapacity method on Text that is similar to
> BytesWritable's. With such a method, it would be possible to shrink the size
> of the backing array.
>
>
HADOOP-6476 in place for this.



> -- Owen
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message