You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@lucene.apache.org by Timo Nentwig <lu...@nitwit.de> on 2008/11/22 17:35:17 UTC

OpenBitSet.trimTrailingZeros() doesn't free memory

Hi there,

IMHO it doesn't make much sense that trimTrailingZeros() doesn't shrink the 
array. Sure the arraycopy() will take some extra time and simply adjusting 
wlen still has the benefit that it will probably speed up the bit set 
operations as there are less bits to be operated on.

On the other hand if you have a lot of bit sets and use to serialize them you 
will waste memory (and time).

I think there should be at least a additional method that explicitly frees the 
memory.

Timo

---------------------------------------------------------------------
To unsubscribe, e-mail: java-dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-dev-help@lucene.apache.org


Re: OpenBitSet.trimTrailingZeros() doesn't free memory

Posted by Timo Nentwig <lu...@nitwit.de>.
On Saturday 22 November 2008 18:15:45 Yonik Seeley wrote:
> On Sat, Nov 22, 2008 at 11:35 AM, Timo Nentwig <lu...@nitwit.de> wrote:
> > IMHO it doesn't make much sense that trimTrailingZeros() doesn't shrink
> > the array. Sure the arraycopy() will take some extra time and simply
> > adjusting wlen still has the benefit that it will probably speed up the
> > bit set operations as there are less bits to be operated on.
>
> I think you just made the case that the current semantics do make sense.
> In any case, stuff like this is exactly why OpenBitSet was designed to
> be "open" - you're not locked out of doing it yourself.

True. I always have to option to do it on my own. However instead of having
everybody to reinvent the wheel why not simply enhance OpenBitSet? Having
the explicit option to free the memory also makes it clear that no memory is 
freed otherwise. IMHO the javadoc currently is not clear on this matter.

just my 2 cents...

> -Yonik
>
> > On the other hand if you have a lot of bit sets and use to serialize them
> > you will waste memory (and time).
> >
> > I think there should be at least a additional method that explicitly
> > frees the memory.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: java-dev-unsubscribe@lucene.apache.org
> For additional commands, e-mail: java-dev-help@lucene.apache.org

---------------------------------------------------------------------
To unsubscribe, e-mail: java-dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-dev-help@lucene.apache.org


Re: OpenBitSet.trimTrailingZeros() doesn't free memory

Posted by Yonik Seeley <yo...@apache.org>.
On Sat, Nov 22, 2008 at 11:35 AM, Timo Nentwig <lu...@nitwit.de> wrote:
> IMHO it doesn't make much sense that trimTrailingZeros() doesn't shrink the
> array. Sure the arraycopy() will take some extra time and simply adjusting
> wlen still has the benefit that it will probably speed up the bit set
> operations as there are less bits to be operated on.

I think you just made the case that the current semantics do make sense.
In any case, stuff like this is exactly why OpenBitSet was designed to
be "open" - you're not locked out of doing it yourself.

-Yonik

> On the other hand if you have a lot of bit sets and use to serialize them you
> will waste memory (and time).
>
> I think there should be at least a additional method that explicitly frees the
> memory.

---------------------------------------------------------------------
To unsubscribe, e-mail: java-dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-dev-help@lucene.apache.org