RE: XmlSerialization Object Memory Usage
- From: Michael Cline <MichaelCline@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Thu, 12 Oct 2006 16:29:02 -0700
Dave,
Sorry, I realized after posting that I had been too close to the problem
and my description wasn't completely accurate.
I am creating an object over and over again and adding the new copy to a
hashtable.
So
Hashtable Storage
for( int i = 0; i < 1000; i++ )
{
ComplexObj Obj1 = new ComplexObj();
Storage.Add( i, Obj1 );
}
In one scenario I would manually set the properties of the object, in
another scenario I would have serialized a copy of the object and I would be
reading it in instead of new ComplexObj(). In both cases I have a 'deep
clone' written which creates a 'new' object of the main type and then of the
one complex type that it contains, populates this new object with the values
from itself and then returns that.
I'm measuring the size with the CLR Profiler. It gives me an accurate count
of objects, and a memory size of these objects. It doesn't make sense that
the size of these four 'versions' of exactly the same thing display 4
different sizes.
It's a console app that creates all this and then waits. I show heap with
CLR Profiler and that is where I'm getting the measurements. Do you have a
better mechanism for seeing .NET memory usage?
Any assistance you can offer would be appreciated.
Thanks,
"Dave Hiniker - MSFT" wrote:
Could you clarify the contents of the object (what makes it hundreds of K)?.
And how are you measuring the memory overhead in each case? Thanks!
"Michael Cline" wrote:
Framework 1.1
Our environment requires us to deserialize xml messages into objects.
In doing some memory analysis I've found the following that doesn't make any
sense to me so I was hoping someone could shed some light on the issue.
Simple Object contains a string, int and bool, as well as another complex
object that also contains a string, int and bool.
If I use code to loop through and create identical objects and add them to a
Hashtable, I see each object taking 430K
If I put a method within that object that 'clones' it and returns a new
object, the new object is only 234K.
Changing the scenario to using the XmlSerializer to deserialize the object
from a string, my memory size of a single object grows to 1016K.
If I call my 'clone' method on this object the size is reduced to 488K.
In my simple mind all of these instances are identical, however there are 4
different sizes which cover a large range.
I'm thinking of creating a CodeGeneration application that could create my
'clone' methods for me, but wanted to make sure that what I was seeing had
some logical justification behind it.
Also, does this behavior change in .NET 2.0 or 3.0? Is there any way for me
to get my 'deserialized' version of the object to be down to the 234K size?
Thanks
- Prev by Date: RE: XmlSerialization Object Memory Usage
- Next by Date: Re: System uses 50% of cpu usage on computer at all times.
- Previous by thread: RE: XmlSerialization Object Memory Usage
- Next by thread: RE: XmlSerialization Object Memory Usage
- Index(es):
Relevant Pages
|
Loading