Page 1 of 1

strings, xml deserialize?

Posted: Fri Sep 02, 2005 4:58 pm
by feto
How can we avoid the memory allocated by the strings? Out application uses a lot of logging, hence a lot of stings and I have a feeling they are causing the issue.

Also, any idea if the xml deserializing causes memory leaks?

Posted: Mon Sep 05, 2005 8:31 pm
by Andreas Suurkuusk
What kind of problem are you experiencing with the allocated strings?
Are you seeing excessive memory usage by String instances, or are there simply a lot of strings allocated? Logging could cause a lot of allocated string instances, but it should not lead to excessive memory usage, unless there is a memory leak or if you're logging to memory.

AFAIK, there are no leaks when deserialing XML. Are you having memory problems when working with XML?

I've got same problem

Posted: Mon Apr 03, 2006 3:17 pm
by CarlVerret

After watching the 3rd tutorial on this site, I began beeing concerned about memory leaks, especially memory used by strings. I've got an enormous amout of memory that never seems to be freed (about half of all string instances never deallocate).

Is there any way to investigate string usage ? I wonder how could I resolve total memory alloc peaks.

Any ideas would be greatly appreciated. Thanks

Posted: Wed Apr 05, 2006 6:53 pm
by Andreas Suurkuusk
I'm not sure what your problem is. You mention that you have string instances that are never freed. Do you see these instances as "Live instances" (i.e. reachable instances), or only as additional "Total instances" (i.e. instances that are not reachable but have not yet been GCed)?

To avoid unnessary memory overhead, you should try to avoid promoting instances to higher generations. This is often not very easy, but you should try to keep the life-time of instances as short as possible (as shown in Tutorial 3). Have you tried to enable the heap utilization tracker? It will help you locate methods that allocate instances that get promoted to higher generations.

You enable the heap utilization tracker using the Tools->Settings dialog. To view how the heap is utilized, you should select the "Heap utilization" classes view.

For optimal behavior, all instances should be GCed in generation #0. When the heap utilization tracker is enabled, you will also be able to collect a heap snapshot using only a gen #0 GC. After this snapshot you will be able to see how many instances that still reside on the GC heap even though they're not reachable from any root. You will also be able to identify the methods (and call stacks) that create these instances.

Re: strings, xml deserialize?

Posted: Wed May 02, 2012 10:09 am
by n/a

Re: strings, xml deserialize?

Posted: Wed May 02, 2012 10:18 am
by n/a
There's also a blog : ... 32804.aspx
And a Support entry about XmlSerialization :