Memory 'leak'?! how to track down?

  • Thread starter Thread starter Adam Hearn
  • Start date Start date
A

Adam Hearn

Application setup is a 'standard' fat client communicating using .NET
Remoting (custom channel) to a Windows service. Most of the application is
C# but on the server there is a little bit of managed C++ to wrap up a C DLL
from a 3rd party.

Basic steps (very summarised!) to highlight my problem:
Client makes a connection to the service
Client calls method on connection object to reconstruct existing object from
a file
Server side BL uses the XML string (read from file) and the .NET XML
Serialiser to create an
object of the required type
Client is then given a reference to this object.

The serialised XML file size is around 2MB (but can be large - MUCH
larger!!!). I notice that the VM size tracked in Task Manager grows a hell
of a lot more than 2MB so I rooted around and bought a memory analyser tool
(Scitech Software). It's very good at showing me the .NET allocations - I
can see that I've created a number of classes and the size and numbers look
OK to me. However, they list <Other> as an item and the memory listed
against it is huge! I did a quick debug step through the code and saw some
possible issues - the XML serialiser objects seemed to take huge amounts of
memory and none of it is ever released?! It would seem to me that I'm either
doing something wrong, .NET (I'm on V1.0) is doing something wrong and/or
I've orphaned some objects and not dereferenced them properly (although the
tool I've got is not highlighting this last point as an issue!). Could I be
correct in thinking that the serialisation usage could be an issue

Just a little more info - one of my class serialisation files is 27.5MB and
by the time I've loaded it and shown some data on the screen the service
process has 1GB VM allocated!! I've tried forcing GC to run and it does
release a little but not much in comparison to what's being used!

Here's my simple deserialisatoin code in server side BL for the object in
question:

XmlDocument xmlDoc = new XmlDocument();
xmlDoc.InnerXml = inXML;

XmlSerializer serializer = new XmlSerializer( typeof( CMyObject ) );
XmlParserContext context = new XmlParserContext( null, null, null,
XmlSpace.None );
XmlReader xmlReader = new XmlTextReader( xmlDoc.OuterXml,
System.Xml.XmlNodeType.Document, context );
CMyObject myObject = (CMyObject) serializer.Deserialize( xmlReader );
xmlReader.Close();

I know it's a shot in the dark but can anyone give me some pointers on where
to start looking - I finding it a little overwhelming at the moment!

Many thanks in advance!
 
Back
Top