启动VB.NET表单作为单独的进程

时间:2022-03-25 15:50:58

I have VB.NET application in which one of the form has IE control in it, the application starts initially with memory size consumed around 9 MBs, but when IE form is launched, the memory consumed rises to 27 MB, and when that form is closed, the memory reduces merely by 3-4 MBs, so why memory allocated to IEFrame is not de-allocated automatically? is there any work around to solve this issue? if possible, launching the form as a separate process would be helpful.

我有VB.NET应用程序,其中一个窗体中有IE控件,应用程序最初启动时内存大小消耗大约9 MB,但是当IE窗体启动时,消耗的内存增加到27 MB,当这个窗体是关闭,内存只减少3-4 MB,那么为什么分配给IEFrame的内存不会自动解除分配?有没有解决这个问题的工作?如果可能的话,将表单作为单独的过程启动会很有帮助。

3 个解决方案

#1


2  

If you make sure to dispose the form properly, the garbage collector should free up that memory eventually. Running the IE control in a separate process should not be necessary. However, if you are using IE 7, you might want to read this question about memory leaks.

如果确保正确处理表单,垃圾收集器最终应释放该内存。不需要在单独的进程中运行IE控件。但是,如果您使用的是IE 7,则可能需要阅读有关内存泄漏的问题。

#2


1  

Why not just put that form in a separate application if this is an issue? There are plenty of ways you can pass whatever data between the two apps.

如果这是一个问题,为什么不将该表单放在单独的应用程序中?有很多方法可以在两个应用程序之间传递任何数据。

#3


0  

The still allocated memory might not be an issue at all. If you have sufficient available memory in the computer the .NET Garbage Collector will not run to clean up. Only when you need the memory the GC will kick in.

仍然分配的内存可能根本不是问题。如果计算机中有足够的可用内存,则.NET垃圾收集器将无法运行以进行清理。只有当您需要内存时,GC才会启动。

If you want to make sure it is a leak you could do the following:

如果您想确保它是泄漏,您可以执行以下操作:

  1. Make sure you have no references to the form in any way.
  2. 确保您没有以任何方式引用表单。
  3. Call GC.Collect()
  4. 调用GC.Collect()
  5. See if the memory is still claimed
  6. 查看是否仍然声明了内存

Do not put the GC.Collect() in the final build; it's just to make sure you are not hunting ghosts.

不要将GC.Collect()放在最终版本中;这只是为了确保你不是在追捕幽灵。

#1


2  

If you make sure to dispose the form properly, the garbage collector should free up that memory eventually. Running the IE control in a separate process should not be necessary. However, if you are using IE 7, you might want to read this question about memory leaks.

如果确保正确处理表单,垃圾收集器最终应释放该内存。不需要在单独的进程中运行IE控件。但是,如果您使用的是IE 7,则可能需要阅读有关内存泄漏的问题。

#2


1  

Why not just put that form in a separate application if this is an issue? There are plenty of ways you can pass whatever data between the two apps.

如果这是一个问题,为什么不将该表单放在单独的应用程序中?有很多方法可以在两个应用程序之间传递任何数据。

#3


0  

The still allocated memory might not be an issue at all. If you have sufficient available memory in the computer the .NET Garbage Collector will not run to clean up. Only when you need the memory the GC will kick in.

仍然分配的内存可能根本不是问题。如果计算机中有足够的可用内存,则.NET垃圾收集器将无法运行以进行清理。只有当您需要内存时,GC才会启动。

If you want to make sure it is a leak you could do the following:

如果您想确保它是泄漏,您可以执行以下操作:

  1. Make sure you have no references to the form in any way.
  2. 确保您没有以任何方式引用表单。
  3. Call GC.Collect()
  4. 调用GC.Collect()
  5. See if the memory is still claimed
  6. 查看是否仍然声明了内存

Do not put the GC.Collect() in the final build; it's just to make sure you are not hunting ghosts.

不要将GC.Collect()放在最终版本中;这只是为了确保你不是在追捕幽灵。