OutOfMemoryException,大量私有数据

发布于 2024-08-27 13:40:42 字数 885 浏览 4 评论 0原文

在之前的系列中:

OutOfMemoryException,堆栈大小巨大,大量线程

我有一个消耗大量内存的.net windows 服务。 GC堆并不大。而且堆栈大小也不大。大的是所谓的私人数据。我还可以在任务管理器中看到我的应用程序消耗了任务管理器调用句柄的很多东西。我的应用程序消耗 2326 个句柄。我相信这些句柄是一些占用私有数据的窗口句柄。我可以看到这个私有数据被占用 标记为线程环境块的块。那是什么?

VMMap 的应用程序内存使用情况的屏幕截图

任务管理器的应用程序内存使用情况的屏幕截图

更新

我运行 ProcessExplorer。目前我的服务有两个实例正在运行。 我可以看到它们为 Gen2 GC 消耗了大量的虚拟内存。这看起来很可疑。 此外,两个进程为 GC 堆保留的总大小是相同的。

替代文本

In previous series:

OutOfMemoryException, stack size is huge, large number of threads

I have a .net windows service that consumes a lot of memory. The GC heap is not big. Also the stack size is not big. What is big is something called a private data. Also I can see in task manager that my application consumes a lot something that taskmanager calls a handle. My application consumes 2326 handles. I believe that these handles are some windows handles that occupy private data. I can see that this private data is occupied by
blocks marked as Thread Environment Block. What is that?

Screenshot of my application memory usage by VMMap

Screenshot of my application memory usage by Task Manager

UPDATE

I run ProcessExplorer. I have two instances of my service running at the moment.
I can see that they consume a lot of virtual memory for Gen2 GC. This look suspicios.
Also total reserved for GC Heap size is the same for two processes.

alt text

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

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

发布评论

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

评论(2

相守太难 2024-09-03 13:40:42

当新创建的对象无法被收集时,您似乎遇到了经典的内存泄漏,因为它们是从垃圾收集根引用的。

摆脱此类问题的最有效方法是使用 WinDBG + SOS 和 !gcroot 命令。可以在此处找到内存泄漏错误调查的示例:http://blogs.msdn.com/tess/archive/2008/04/03/net-debugging-demos-lab-7-memory-leak-review.aspx

祝你好运!

It seems that you have classic memory leak, when newly created objects can not be collected because they are referenced from a garbage collection roots.

The most effective way to get rid of such problem - use WinDBG + SOS and !gcroot command. Example of memory leak bug investigation can be found here: http://blogs.msdn.com/tess/archive/2008/04/03/net-debugging-demos-lab-7-memory-leak-review.aspx

Good luck!

許願樹丅啲祈禱 2024-09-03 13:40:42

是的,相当消耗资源。我猜测您用 [ThreadStatic] 属性标记的变量。您的线程方式太多了。

Yes, quite a resource hog. I'm guessing at variables you've marked with the [ThreadStatic] attribute. You've got way too many threads.

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