Reputation: 690
A simple sample application that has zero functionality shows a surprising difference in memory utilization.
Numbers are in private bytes and using .NET 4.0.
Frameworks are notoriously bad at doing nothing, but I'm still surprised by this difference. Can I expect that an application built with WPF will consume 30-40MB more in private bytes as a cost of using WPF?
Upvotes: 2
Views: 2299
Reputation: 96730
I recommend that you try creating a UI with 10,000 controls in it in WPF, and a similar UI in WinForms, and then check to see what the memory usage is. It's fairly simple to do this programmatically - just create a Form and add 10,000 TextBox
objects to its Controls
collection, for instance. (Spoiler alert: you'll need to use a number that's smaller than 10,000 with WinForms.) This won't give you an especially accurate point of comparison either, but it's a more accurate one than an app that does nothing, and it will teach you a valuable lesson about windowless controls.
Upvotes: 4
Reputation: 17272
WPF (and its basic controls) offer much more features, so increased overhead is to be expected.
The advantage of WPF is that it is more "developer time efficient" (to create rich UIs) than WinForms, not more "memory efficient" or "CPU efficient".
Though since WPF is fully GPU-accelerated, performance gains are to be expected in some cases. But these are not the performance gains you can see in task manager, these become apparent in form of increased animation smoothness and user responsiveness.
Upvotes: 0
Reputation: 437406
From this data, no. What you can deduce is that an application that does exactly nothing will consume 43MB more in WPF.
My point being that as more features get used by the application, the difference might increase, decrease, or stay constant. No way to know.
Upvotes: 6