Prism 模块生命周期
我开发了一个 silverlight prism 项目来复制内存泄漏。只是想知道棱镜模块的生命周期。
如果在模块内注册一个视图,当模块不再使用时,该视图是否会被销毁?
另外,每个模块是否共享相同的依赖容器(例如 unity),还是每个模块都有一个单独的依赖容器?
我在这里有一个更深入的问题,
https://stackoverflow.com /questions/4652364/memory-usage-is-suspect-when-loading-prism-modules
我试图了解打开和关闭棱镜模块时内存使用的一些差异。
I have developed a silverlight prism project to replicate a memory leak. Just wondering about the lifecycle of a prism module.
If inside a module I register a view does the view get destroyed when the module is no longer in use?
Also does each module share the same dependency container (e.g. unity) or does each module have a separate one?
I have a more in depth question here,
https://stackoverflow.com/questions/4652364/memory-usage-is-suspect-when-loading-prism-modules
I am trying to understand some discrepancies with memory usage when opening and closing prism modules.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
1) 视图被销毁的时间点取决于您将视图注册到容器的方式。如果您在注册期间没有更改对象生命周期,那么当 GC 发现它而没有任何对象引用它时,它将被销毁。如果您在注册期间显式指定生命周期管理器,则视图将根据管理器管理的特定生命周期被销毁。一个例子:当您使用 Unity 容器并使用 ContainerControlledLifetimeManager 注册视图时,当容器被销毁时,视图也会被销毁。
2)所有模块共享一个容器,只要你不为每个模块单独创建一个子容器。
1) The point in time the view gets destroyed depends on the way you have registered the view to the container. If you didn't change the object lifecycle during registration, it will be destroyed when the GC finds it without having any object referencing it. If you explicitly specified a lifetime manager during the registration the view gets destroyed depending on the particular lifetime the manager manages. An exmaple: When you are using a Unity container and you registered the view with a ContainerControlledLifetimeManager the view gets destroyed when the container gets destroyed.
2) All modules share one container as long as you don't make a child container for each module on your own.