[Mono-devel-list] PATCH: Lazily allocate ArrayList buffers

Steinar Herland steinar.herland at gecko.no
Tue Feb 17 03:59:01 EST 2004


How about #define this according to the appropriate framework-version?

-----Original Message-----
From: mono-devel-list-admin at lists.ximian.com
[mailto:mono-devel-list-admin at lists.ximian.com] On Behalf Of Martin
Baulig
Sent: 17. februar 2004 09:43
To: Ben Maurer
Cc: Mono Development
Subject: Re: [Mono-devel-list] PATCH: Lazily allocate ArrayList buffers

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.

Hi Ben,

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

_______________________________________________
Mono-devel-list mailing list
Mono-devel-list at lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-devel-list





More information about the Mono-devel-list mailing list