VB6应用程序调用.NET DLL OutOfMemory异常 [英] VB6 App Calling .NET DLL OutOfMemory Exception

查看:147
本文介绍了VB6应用程序调用.NET DLL OutOfMemory异常的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们有一个VB6应用程序调用.NET DLL。有时VB6应用程序运行了很长时间并且已经调用了.NET代码,.NET边的东西会抛出一个OutOfMemory异常,即使机器上有足够的内存可用。 VB6的内存空间也没有附近的限制。



.NET端是否保留单独的内存池?还是VB6应用程序的内存池呢?



如果是分开的,有没有办法看看它有多大?我的任务管理器中唯一巨大的内存条目是SQL Server和VB6应用程序(均为预期)。



这不是太频繁,但是当它这样做时,很难确定为什么系统不会分配更多的内存。

解决方案

答案最终非常简单:



使用DEBUG配置构建的.NET DLL运行时泄漏



切换到RELEASE版本修复了我的问题。



背景:



我终于得到ANTS调试VB6应用程序,看到.NET进程(不得不更改VB6代码以尽快加载.NET代码)。一旦我这样做,我看到了大量的弱引用对象,其父对象是__ENCList。此类允许在调试期间编辑和继续。这是一个快速的Google搜索,这是由使用DEBUG构建引起的。



我的Google搜索



链接:



调试构建中的弱参考


We have a VB6 app that calls out to a .NET DLL. Occasionally, after the VB6 app has been running for a long time and has called the .NET code a lot, the .NET side of things throws an OutOfMemory exception, even though there is plenty of memory available on the machine. The VB6 memory space is also no where near it's limit.

Does the .NET side keep a separate memory pool? Or is it apart of the VB6 app's memory pool?

If it is separate, is there a way to see how big it is? The only huge memory items in my Task Manager are SQL Server and the VB6 app (both expected).

This doesn't happen too often, but when it does, it's hard to pin down why the system won't allocate more memory.

解决方案

The answer ended up being very simple:

A .NET DLL built with DEBUG configuration will leak while running.

Switching to a RELEASE build fixed my issue.

Background:

I finally got ANTS to debug the VB6 app and see the .NET process (had to change the VB6 code to load the .NET code as soon as possible). Once I did that, I saw a huge number of weak referenced objects whose parent was __ENCList. This classes allows for Edit and Continue during debugging. A quick Google search showed immediately this was caused by using a DEBUG build.

My Google Search

Links:

WeakReferences in Debug Build

这篇关于VB6应用程序调用.NET DLL OutOfMemory异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆