[Mono-devel-list] PATCH: Lazily allocate ArrayList buffers
martin at ximian.com
Tue Feb 17 03:42:59 EST 2004
On Sun, 2004-02-15 at 07:10, Ben Maurer wrote:
> Attached is a patch that makes ArrayLists allocate their buffers only on
> the first addition to the list. For example the following code:
> ArrayList ar = new ArrayList ();
> ar = null;
> will not allocate an object .
> Running the profiler on a few applications, it seems that the patch has
> some effect. One notable example is MonoDevelop where it prevented 2/3
> of the allocations of arraylists.
> It seems that MS implements this behavior in the v2 framework. Using a
> beta of the code, I ran:
> ArrayList ar = new ArrayList ()
> COnsole.WriteLine (ar.Capacity);
> It returned 0. This seems to indicate that the capacity (which is the
> size of the array) is zero until something has been added.
your patch looks great, but I think we should really make Capacity
return 0 in this case.
Martin Baulig <martin at ximian.com>
Now blogging ! http://primates.ximian.com/~martin/blog
More information about the Mono-devel-list