[Mono-list] Mono memory usage grows but application memory looks stable

Gonzalo Paniagua Javier gonzalo.mono at gmail.com
Tue Sep 29 04:21:54 EDT 2009

On Mon, 2009-09-28 at 10:24 -0700, Manuel C. wrote:
> Sorry for the late response.
> I tried also version, it's the same. I took me a few days to find
> out that a missing Close() on a GZipStream was the root of all evil. Here is
> an example:
>         static void Decompress()
>         {
>             byte[] file = File.ReadAllBytes("in.dat.gz");
>             Stream stream = new GZipStream(new MemoryStream(file),
> CompressionMode.Decompress);
>             byte[] buffer = new byte[1024];
>             while (stream.Read(buffer, 0, buffer.Length) > 0);
>             // stream.Close();
>         }
> A function similar to this is called very often in my application. Under
> Windows with.Net there is no issue, but with Mono the memory usage will
> increase with every call of Decompress(). I thought the deconstructor of the
> stream will call the Close or Dispose method?

Btw, GZipStream and DeflateStream were rewritten and are available in
svn (mono-2-4, mono-2-6 branches and trunk). The 2.4.2.x series does not
have the new implementation which uses ~10x less memory and is at the
very least as fast as the implementation you're using.


More information about the Mono-list mailing list