开发者

Silverlight TreeView using MVVM pattern has large footprint

I have a Silverlight TreeView where each node is a TreeNodeViewModel. The properties on the TreeNodeViewModel's are, Text, IsSelected, ImageUri, and Parent. I'm loading about 700 to 1000 TreeView items.

What seems to be happening is that after loading the TreeView via the binding in the HierarchicalDataTemplate, the IE Browser's footprint grow's from about 48,000kb to 165,000kb. I'm using a ViewModel for the TreeView itself, which has bindings for ExpandAll and CollapseAll. When I envoke the expand command, the IE footprint continues to grow to almost 300,000kb. Once the tree is fully expanded, repeating expand & collapse does not increase the footprint; that is, it seems to level off once all the ViewModels are created.

My question is, if I'm loading about 800 TreeView items, is it expected that the footprint should be as large as it is in my case? Has anyone ever seen an IE excesive footprint from loading large amounts of data?

Some background on the SL app I'm developing: The hardware device (aka: server) is proprietary hardware and has an embedded web-server, similar to a linksys router. A compressed config file (model entities) is loaded to the device, and the SL app downloads it, decompresses it, and deserializes it using the DataContractSerializer. The file compressed is about 1.75MB, uncompressed is about 12.5MB.

My first th开发者_开发知识库ought was that the IE footprint was large because of the deserialization of the model. Initially when IE starts, the footprint is about 7500kb, loading the model into memory runs it up to 48,000kb.

Any thoughts or suggestions will be greatly appreciated.


May be this is not an answer to your question, but: I do not use standard silverlight controls + silverlight toolkit contols. We've struggled enough fighting their bugs. Just the two of them:

  1. You cannot put datepicker(or timepicher) on childwidow, its styles will fail and you will have to re-declarate in your resourses to get things work.

  2. TreeView - although you can save treeview state(which nodes are expanded and which are not), restoring it is quite tricky. REALLY tricky: nodes are not even created until you expand their parents.

Anyway, what am i talking about? Give up standard conrols as soon as possible, force you bosses to buy Telerik, Devexpress, or whatever you prefer. It's already 4th version of silverlight and wpf, and some basic things cannot be done with out-of-the-box control libraries, memory still leaks, bugs do not get fixed.


I would recommend using a profiler like YourKit profiler or the like to at least get a memory profile on what is taking up the memory. It will help finding out what your hotspots are in terms of memory consumption and help track down any memory leaks.

Is 165MB too much? Can you force a GC.Collect in case this memory usage isn't putting too much pressure on the GC and so may be mostly garbage?

Definitely try out the profiler to get a better idea of the profile of your app.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜