[Mono-osx] [Mono-dev] OS X builds and -DUSE-MUNMAP

Paolo Molaro lupus at ximian.com
Fri Jan 26 13:32:29 EST 2007

On 01/24/07 Eoin Norris wrote:
> Hmm. I am not so sure that this has made it, or works as advertised.  
> i can see - in loading in a very large xml file -
> This bloats to 200MB when reading a 23MB xml file - mostly in  
> doc.LoadXml(_libraryXmlString) as far as I can see ( although without  
> a full debugger it is hard to tell) . I have also would do the same  
> if it were read from disk at this point,   a process that is too slow  
> in any case, so I load in the Cocoa layer instead.
> The size increase is possibly a bug in itself, since the .Net side on  
> windows doing similar code does not bloat to that level.
> In any case the object that encapsulates this functionality does not  
> need to hang around after it's contents are written to a different  
> datastore.
> so I blow it away like so
> 	if (xmlString.Length != 0)
> 		library.PopulateXMLString();
> .. do stuff with the library contents
> 	library = NULL;
> 	GC.Collect();

Due to the way the current implementation of the GC and JIT works, this
doesn't have the effect of removing all the references to the library
object. A pattern that is much more likely to do it is to:

	void worker () {
		theType library = create_library ();
		library.PopulateXMLString ();
		// do something with library

	void Main () {
		init ();
		worker ();
		GC.Collect ();
		do_something_else ();

bacause in this case all references to library are in the stack frame of
the call to worker () and on return it is no more accessible.

> I should add this is really a deal breaker in terms of releasing the  
> product, as you can imagine not releasing large amounts of memory is  
> a big issue.

If it is a big issue you can likely file in bugzilla a complete test case
that we can use to reproduce the issue and eventually fix it. Until that
time it's hard for us to do anything to help you and consider that
USE_UNMAP may be of no help, depending on what the actual issue is
(which we can know only with a complete test).


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

More information about the Mono-osx mailing list