[Mono-devel-list] memory usage in Reflection classes

Paolo Molaro lupus at ximian.com
Wed Jul 2 13:35:11 EDT 2003


On 07/01/03 Varga Zoltan wrote:
>   Currently, the reflection classes call icalls function
> like get_type_info ()
> without caching the result. This means that a simple call like
> Type.IsPrimitive ends up allocating two string on each call.
> This is
> showing up in memory allocation profiles of some
> applications like nunit.
> I would like to know if this behaviour is by design (e.g.
> favoring the
> smaller static memory usage of no caching) or is this a bug
> which can
> be fixed.

Initially I did it that way to reduce the number of needed icalls
and there was no data on what members were best cached or not.
There are several possibilities:
*) cache some info in the object itself
*) introduce more icalls that do just one thing
*) fix the issue in other ways.

Which one to choose depends on the actual issue.
IsPrimitive, for example, could be implemented with GetTypeCode()
and a range compare, I think.
In other cases, for example the name for MonoField could be cached
inside the object: it seems to be used a lot by the serializer.
So, I agree we should cleanup that stuff: adding more specific icalls
would be fine most of the time.

lupus

-- 
-----------------------------------------------------------------
lupus at debian.org                                     debian/rules
lupus at ximian.com                             Monkeys do it better



More information about the Mono-devel-list mailing list