User avatar
ai_enabled
Topic Author
Posts: 221
Joined: 18 Jul 2013, 05:28
Contact:

MergedDictionaries question

25 Jan 2016, 08:23

Hello!
Does NoesisGUI behaves in the same way as WPF regarding the MergedDictionaries? I mean does it create a new instance of ResourceDictionary for each dictionary defined at MergedDictionaries or reuse them like a "SharedMergedDictionary" approach? (described here http://www.wpftutorial.net/MergedDictio ... mance.html )
If it doesn't reuse them, are there any possibility to implement SharedMergedDictionary in C# (maybe for NoesisGUI v1.3?). Currently I have no luck with the same code from tutorial above.

Also I would be interested to see a documentation about the best approach of dividing XAML resources on multiple ResourceDictionaries (with performance/efficiency considerations).

Regards!
AtomicTorch Studio Pte. Ltd. http://atomictorch.com
 
User avatar
sfernandez
Site Admin
Posts: 1918
Joined: 22 Dec 2011, 19:20

Re: MergedDictionaries question

26 Jan 2016, 17:33

Hi,

Right now all ResourceDictionaries referenced in a XAML are cached and shared by default in NoesisGUI. Referencing a "Resources.xaml" from different XAMLs will load the same instance of the ResourceDictionary, so all the resources defined there (templates, brushes,...) can be shared.

This is something we know is different in WPF, but we didn't understand what's the point of loading the same dictionary every time, replicating the same resources in memory for every user control that references a common dictionary.

Maybe it will be better to implement something like the SharedMergedDictionary, so users can decide if they want to share resource or load a new instance.

What do you think?
 
User avatar
ai_enabled
Topic Author
Posts: 221
Joined: 18 Jul 2013, 05:28
Contact:

Re: MergedDictionaries question

27 Jan 2016, 08:42

Thanks for your reply!
but we didn't understand what's the point of loading the same dictionary every time, replicating the same resources in memory for every user control that references a common dictionary.
AFAIK, the point is that when the UserControl is unloaded, all defined in the UserControl merged dictionaries should be also unloaded. For LOB-applications it makes sense as there are usually hundreds of controls, developed by dedicated engineers/teams, and rarely they uses common resource dictionaries. So specific resource dictionaries are loaded and unloaded when needed. The startup time should be faster in that case, and usually user doesn't need all the controls (and their resources) to be preloaded as he/she will use only fraction of them.
This is a modular approach, but, unfortunately, it's flawed in WPF - most developers don't knew about the memory overhead of it and don't use it properly (I read about certain LOB-applications that uses hundreds of MB of RAM just to store resource dictionaries). So SharedResourceDictionary is a hack to fix this issue, but it seems to have its own drawbacks (the loaded resources dictionaries are never unloaded).

I think your current approach is best fit for video games. So for us it's exactly what we need :-).

Regards!
AtomicTorch Studio Pte. Ltd. http://atomictorch.com

Who is online

Users browsing this forum: No registered users and 1 guest