[Mono-dev] Issues with GC due to libgc

Miguel de Icaza miguel at novell.com
Mon Sep 28 17:41:33 EDT 2009


Hello,

> Libgc supports this kind of descriptors and mono already generates
> them
> for the sgen gc, so it's just a matter of joining those together
> (which
> should beeasy to do). This should improve a great number of scans in
> the
> arking process, leaving only stacks and several minor objects without
> precise marking. (Should become similar to the current sgen idea,
> where
> stacks and other roots are scanned conservatively, although not
> compacting).

Mono already uses those descriptors for the heap;   There are only two
cases when it does not use that:

	* Scanning the stack, this is done with the conservative 
	  collector.

	* Any AppDomains that are not the root appdomain.    

The problem with scanning the stack precisely is that it requires the
JIT and the GC to work as a team to be able to at any point of the
execution to determine which values on the stack are pointers and which
values are not.    This is not trivial.

The problem with AppDomains is that upon unloading there is a potential
for leaking vtables, something that I do not particular think is as
important as being able to scan the AppDomains precisely.   We should
bring Ben's patch into Mono and just default to this.

There are ways of minimizing the problems that you are experiencing
today, some techniques might work better than others, but:

	* Do not allocate large blocks of data, as they tend to fragment
	  your heap;   Instead use smaller allocations, or use unmanaged
	  buffers if you need to.

	  This technique is used in Mono's ASP.NET precisely for that
	  reason.

	  See System.Web/HttpResponseStream.cs

	* Make your stacks shallower.

Miguel.



More information about the Mono-devel-list mailing list