温莎城堡 - 为什么我不想使用“NoTrackingReleasePolicy”?作为默认值?
我来自 StructureMap 世界,在那里永远不需要释放已解析的瞬态对象。
我看到 Windsor 默认跟踪任何已解析的瞬态对象,因此阻止它们被垃圾收集,直到它们被释放(如果它们被释放)。
我在文档中找到了NoTrackingReleasePolicy,但它的用法不鼓励使用。
对我来说,必须释放任何瞬态对象就像回到过去一样。
我将在我的应用程序中使用 NoTrackingReleasePolicy。
我这样做会遇到什么麻烦?或者换句话说,为什么我想手动释放对象而不是让垃圾收集器为我处理它?
I come from the StructureMap world, where it is never necessary to release resolved transient objects.
I see that Windsor by defauly keeps track of any resolved transient objects and therefore prevents them from being garbage collected until they are released (if they ever are released).
I found NoTrackingReleasePolicy in the docs, but it's usage is discouraged.
Having to release any transient objects seems like going back in time to me.
I will use NoTrackingReleasePolicy in my app.
What trouble am I getting into by doing this? Or in other words why would I want to release objects manually instead of having the garbage collector handle that for me?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
只是为了这个问题不会得不到解答:
这个问题在博客文章 由 @mauricio scheffer 在评论中链接。
基本上使用 NoTrackingReleasePolicy 会导致很多微妙的问题,如果您使用默认的发布策略正确构建应用程序,则无论如何都不必担心在代码中显式调用发布。
Just so that question doesn't stay unanswered:
The matter is explained in the blogpost linked by @mauricio scheffer in the comments.
Basically using NoTrackingReleasePolicy is going to lead to a lot of subtle problems, and if you architect your app right, with the default release policy, you don't have to worry about calling release explicitly in your code anyway.