[Mono-list] appdomains

Peter Hagen peter at wingsofdeath.nu
Fri May 2 05:43:13 EDT 2008


Hi

i have a very strange resource problem. I'm using the  
GemBox.Spreadsheet dll and it seemed that somehow the resources (or  
something) aren't freed on finishing. I did a manual GC.Collect and  
could see that the garbage collector did release the memory, but when  
looking into top or some kind of proces list, the memory was still in  
use. If I ran it a second time, it would even allocate more memory.  
The only way the memory is freed, is on killing xsp of apache. So, I  
thought I should use a different AppDomain. After sometime I got i  
working, but unfortunally, the memory is still not freed! I have the  
same issue with mono 1.9.1 and 1.2.6. According to GemBox, the  
GC.Collect should clean up the memory. Here is my code:


			AppDomainSetup setup = new AppDomainSetup();
			setup.ApplicationBase = Path.Combine 
(ApplicationInfo.ApplicationPath, "bin");
			setup.PrivateBinPath = ApplicationInfo.ApplicationPath;
			setup.ApplicationName = "CsvImport";
			AppDomain appDomain = AppDomain.CreateDomain("Converter", null,  
setup);
			
			try {
				//Console.Error.WriteLine("Checkpoint 1");
				ObjectHandle oh = (ObjectHandle)appDomain.CreateInstanceFrom 
(Path.Combine(Path.Combine(ApplicationInfo.ApplicationPath, "bin"),  
"DMICTService.Converter.GemBoxSpreadsheet.dll"),  
"DMICTService.Converter.GemBoxSpreadsheet.GemBoxConverter");
				//Console.Error.WriteLine("Checkpoint 2");

				object o = oh.Unwrap();

				//if (o != null)
				//	Console.Error.WriteLine("o={0}", o.GetType());

				if (o is iAppDomainConverter) {
					// Console.Error.WriteLine("we have a iAppDomainConverter");

					iAppDomainConverter conv = (iAppDomainConverter) o;
					// Console.Error.WriteLine(conv.ToUpper("test"));

					Willow.Common.IO io = new Willow.Common.IO();
					Encoding enc = io.TextFileEncodingGuess(path);

					if (conv.LoadFileCsv(path, seperator, enc))
						Console.Error.WriteLine("csv file loaded");
				}
			} finally {
				AppDomain.Unload(appDomain);
				appDomain = null;
			}

I thought that running something in a different domain would seperate  
the memory usage etc. So, shouldnt this construction clean up the  
memory?

with kind regards

Peter Hagen
peter at wingsofdeath.nu
www.WingsOfDeath.nu



-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.ximian.com/pipermail/mono-list/attachments/20080502/930ef912/attachment.html 


More information about the Mono-list mailing list