[Mono-devel-list] xsp.exe virtual size grows without bound -- large messages

jrodman at mono-list.spamportal.net jrodman at mono-list.spamportal.net
Wed Dec 15 20:51:01 EST 2004

Hello Monoites,

We're using xsp to host a relatively trivial SOAP-based web service
which receives binary files.  The files are sent as byte[] arrays in
single calls.  This uses a fair amount of memory, and may not be
optimally efficient, but for our purposes that's probably fine, and
there are significant reasons to be using as vanilla SOAP as possible.

Particulars: This is an Opteron box, with one gig of ram, running SuSE
	Linux Enterprise Server 9, mono 1.0.5 from downloaded (binary)
	x86 packages.

I have two problems with this setup.

The small quibble:

Under mono, both the client and the server, to send a single large
binary file, will allocate memory in the ballpark of 9 times the file's
size.  I am quite explicitly pulling the entire file into memory, and
understand that the client is likely encoding that entire data in memory
rather than sending it while encoding.  

That's fine, and should probably use around 2 to 3 times the original
file size, due to encoding overhead.

What I'm seeing, however is mono using in the ballpark of 9 times the
file's size, which is a bit of a style cramp.  We expet to be
transmitting files in the kilobytes to megabytes range, with extreme
cases of up to around 20-30 megabytes, where it gets ugly, and programs
swell into the hundreds of megabytes of virtual size.

For comparison, Microsoft's runtime seems to keep to roughly 1/3rd the
size of an equivalent Mono run.  That's comparing Task Manager's listing
of Microsoft's runtime on Windows to ps aux's listing of mono on Linux.

The serious problem:

xsp.exe's virtual size grows larger with every data transmission.  After
enough transactions, xsp will begin to swap heavily, and the time to
transmit will go from on the order of 1 second per megabyte of data down
to as bad as 15 seconds per megabyte of data.  I'm sure it will only get
worse but when my shell and X session and so on have all long since
beeen swapped it I lose patience with exploring the extent of the

It's possible this is some foolish newbie mistake, but I've tried to
strip it down to the absolute minimum and sanity check my understanding
of everything I'm doing with peers, and I really don't think so.

Attached you can find a trivial server and client which I have been
using to produce this behavior. 

Thank you for your feedback and test results.

Joshua Rodman
-------------- next part --------------
using System.Web;
using System.Web.Services;

namespace Program.SoapApi
	public class WebService : System.Web.Services.WebService
		public string SubmitFile(string fileName,byte[] buffer)
			if (buffer.Length > 0)
				return "hi";
				return "bye";

-------------- next part --------------
using System.IO;
using System.Threading;

namespace ExNamespace
	public class Utility
		public static byte[] ReadFileToBuffer(string fileName)
			int buffSize ;
			byte[] buffer;
			FileInfo fi = new FileInfo(fileName);
			buffSize = (int)fi.Length;
			buffer = new byte[buffSize];

			FileStream fs = new FileStream(fileName, FileMode.Open, FileAccess.Read);
			fs.Read(buffer, 0, buffSize);

			return buffer;

	public class DemoClient
		WebService webSvc;
		public static void Main(string[] args)
			WebService webSvc = new WebService();
			string filePath = args[0];
			byte[] local_buffer;

			local_buffer = Utility.ReadFileToBuffer(filePath);	

			string baseName = Path.GetFileName(filePath);
			string token = webSvc.SubmitFile(baseName, local_buffer);	
-------------- next part --------------
<%@ WebService Language="c#" Codebehind="server.cs" Class="Program.SoapApi.WebService" %>

More information about the Mono-devel-list mailing list