使用 Workflow 4.0 SqlWorkflowInstanceStore 和 PersistableIdleAction.Unload 时出现内存泄漏

发布于 2024-08-31 09:19:06 字数 973 浏览 1 评论 0原文

这个特殊的问题让我发疯。我想知道是否有人遇到过类似的问题。如果我加载工作流程然后卸载它并执行内存快照,那么结果是可预测的 - 我的工作流程不再位于内存中。但是,如果我加载工作流并将 PersistableIdle 操作设置为 PersistableIdleAction.Unload 并让工作流空闲,则即使 Unload 操作触发,工作流仍保留在内存中。

我使用 ANTS Memory Profiler 来调试这个问题。这是输出的对象保留图,显示内部对象挂在我的工作流实例上。

替代文本
(来源:rohland.co.za< /a>)

其他人可以验证这个问题吗?我的代码如下:

  1. 创建 SqlWorkflowInstanceStore 并设置锁所有者句柄
    -- 此时,我拍摄内存快照
  2. 创建 Workflow1 的实例
  3. 设置 PersistableIdle 操作
  4. 将实例存储应用到 Workflow1
  5. 设置 Idle、Unload、UnhandledException 等的操作事件处理程序
  6. 保留工作流实例
  7. 运行工作流实例
  8. 等待实例空闲 (由延迟活动引起)
  9. 确保触发卸载操作
    -- 此时,我拍摄了第二个内存快照

从上图中,很明显,引用 Workflow1 的唯一对象是一些我无法处理的内部事件处理程序结果。

有什么线索吗?

This particular problem is driving me nuts. I wonder if anyone has experienced a similar problem. If I load up a workflow then unload it and perform a memory snapshot then the result is predictable - my workflow is no longer in memory. However, if I load up a workflow and set the PersistableIdle action to PersistableIdleAction.Unload and let the workflow idle the workflow remains in memory even though the Unload action fires.

I used ANTS Memory Profiler to debug this issue. This is the object retention graph outputted showing that an internal object is hanging onto my workflow instance.

alt text
(source: rohland.co.za)

Can anyone else verify this problem? My code amounts to the following:

  1. Create SqlWorkflowInstanceStore and setup lock owner handle
    -- At this point I take a memory snapshot
  2. Create an instance of Workflow1
  3. Set the PersistableIdle action
  4. Apply the instancestore to Workflow1
  5. Setup action event handlers for Idle, Unload, UnhandledException etc.
  6. Persist the workflow instance
  7. Run the workflow instance
  8. Wait for instance to idle (caused by Delay activity)
  9. Ensure the Unload action is fired
    -- At this point I take a second memory snapshot

From the above image, it is clear that the only object referencing Workflow1 is some internal event handlers result which I have no ability to dispose of.

Any clues?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

与往事干杯 2024-09-07 09:19:06

看起来是一个有趣的错误?我没有你提到的分析器,所以有几个问题。

  • 您的调查是否由一些重大的内存使用问题驱动?

  • 您有多确定卸载操作在分析时确实完成(相对于即将异步发生等)?

  • 看起来异步链没问题,但 TdsParserStateObject 可能是泄漏的真实对象。我注意到该类有一个 Dispose() 方法,但没有实现 IDisposable。因此,另一个想法是 Dispose() 用于在某个不同的时间点手动“重置”或“回收”对象 - 但该时间点结果是“尚未(卸载时间)但稍后”,例如懒惰回收。您的分析器是否可以让您查看 TdsParserStateObjects 的数量是否随着时间的推移而增加,以表明那里存在真正的泄漏?与“只是有限数量的对象,因此不是真正的泄漏”泄漏相反。

Seems like an interesting bug? I don't have the profiler you mention so a couple questions.

  • Is your investigation driven by some significant memory usage problems?

  • How sure are you that the unload action is really completed at the time of profiling (vs about to happen asynchronously, etc)?

  • It seems like the asynchronous chain is OK but the TdsParserStateObject would probably be the real object being leaked. I notice that class has a Dispose() method but doesn't implement IDisposable. So another idea is that Dispose() is used to manually 'reset' or 'recycle' the object at some distinct point in time - but that point in time turns out to be 'not yet (unload time) but later', e.g. lazy recycling. Does your profiler let you see whether the number of TdsParserStateObjects over time is increasing, to indicate a real leak there? As opposed to 'just a finite number of objects so not a real leak' leak.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文