KB4525236更改了GetRef的内存消耗(垃圾回收) [英] GetRef's memory consumption (garbage collection) changed with KB4525236

查看:202
本文介绍了KB4525236更改了GetRef的内存消耗(垃圾回收)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在安装之后,我们会遇到内存不足的问题Windows 2016 Servers/Windows 10 Clients上的KB4525236 .通过GetRef调用函数时,内存被垃圾回收的那一刻,此安全修复程序似乎已更改.

We experience out-of-memory issues after installing KB4525236 on our Windows 2016 Servers/Windows 10 Clients. This security fix seems to have changed the moment when memory is garbage collected when calling a function through GetRef.

在通过GetRef调用的函数中创建的每个实例都在实例变量设置为nothing

Each instance created in a function called through GetRef got garbage collected as soon as the instance variable was set to nothing

在通过GetRef调用的函数中创建的每个实例都保留在内存中,并且仅在整个函数完成后才会收集垃圾.在循环中创建实例时,这可能会迅速累加并导致内存不足,尤其是在32位进程中.

Each instance created in a function called through GetRef remains in memory and is garbage collected only when the entire function completes. When creating instances in a loop, this can quickly add up and lead to an out-of-memory, especially in a 32-bit process.

  • 我们在网上找不到任何相关内容,因此我们希望得到其他遇到相同问题的确认.
    编辑:
  • we can not find anything relevant online so we would like to get confirmation from others experiencing the same issue.
    EDIT scratch that: this is the same issue but with no solution as of yet
    (vbscript.dll class_terminate bug since KB4524570 (November 12, 2019) Windows 10 1903)
  • if anyone can verify and knows a workable solution, that would be awesome.

在安装了KB4525236的设备上运行以下脚本显示了何时进行垃圾收集的区别

following script running on a device with KB4525236 installed shows the difference in garbage collecting when

  • 直接调用:第二个实例仅在 之后被创建(这是我们期望的行为)
  • 通过GetRef调用:第二个实例在创建之前 被破坏,因此有两个实例使用内存.
  • called directly: the second instance gets created only after the first instance is destroyed (this is our desired behavior)
  • called through GetRef: the second instance gets created before the first instance is destroyed so whe have two instances using memory.

另存为:KB4525236.vbs
运行方式:wscript KB4525236.vbs

Dim Name, Log

Class IDummyInstance
  Dim FName
  Sub Class_Initialize
    FName = Name
    Log = Log & "Initialize " & FName & VbNewLine
  End Sub
  Sub Class_Terminate
    Log = Log & "Terminate " & FName & vbNewLine
  End Sub
End Class

Sub CreateDestroyTwoInstances
  Dim DummyInstance
  Name = "First Instance"
  Set DummyInstance = New IDummyInstance
  Set DummyInstance = Nothing
  Name = "Second Instance"
  Set DummyInstance = New IDummyInstance
  Set DummyInstance = Nothing
End Sub

Log = "(1) Direct Call :" & VbNewLine
Call CreateDestroyTwoInstances

Log = VbNewLine & Log & "(2) GetRef Call :" & vbNewLine
Set GetRefCall = GetRef ("CreateDestroyTwoInstances")
Call GetRefCall

MsgBox Log

推荐答案

由于我没有解决方案或没有官方消息解释这个问题,所以我在等赏金到期.

Since I don't have a solution or an official source explaining the issue I was waiting the bounty to expire.

我想出了一个不愉快的解决方法,该问题可以在错误修复之前提供帮助.

I've come up with an unpleasant workaround that can help until the bug is fixed.

解决方法是不要使用任何局部变量来保存可能通过GetRef执行的过程中的对象实例.

The workaround is not to use any local variable to hold object instances in procedures that might be executed through GetRef.

使用局部(如果没有递归的话,则是全局)字典对象来保存对象实例并通过该字典调用它们,而不是隐式或显式变量.

Instead of implicit or explicit variables, using a local (or global if there's no recursion) dictionary object to hold object instances and calling them through that dictionary works.

Sub CreateDestroyTwoInstances
  Dim Refs
  Set Refs = CreateObject("Scripting.Dictionary")
  Name = "First Instance"
  Refs.Add "DummyInstance", New IDummyInstance
  ' Call Refs("DummyInstance").DoSomething()
  Refs.Remove "DummyInstance"
  Name = "Second Instance"
  Refs.Add "DummyInstance", New IDummyInstance
  ' Call Refs("DummyInstance").DoSomething()
  Refs.Remove "DummyInstance"
End Sub

如果您的脚本不太复杂,那么似乎值得使用.

It seems to be worth using if you have a script that is not too complicated.

这篇关于KB4525236更改了GetRef的内存消耗(垃圾回收)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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