https://bugs.winehq.org/show_bug.cgi?id=54456
Bug ID: 54456 Summary: vbscript memory leak in For Each with SafeArray as group Product: Wine Version: 7.21 Hardware: x86-64 OS: Linux Status: UNCONFIRMED Severity: normal Priority: P2 Component: vbscript Assignee: wine-bugs@winehq.org Reporter: jsm174@gmail.com Distribution: ---
While porting Visual Pinball to cross platform, I started using XCode Instruments to find some outstanding memory leaks.
Given the following code:
Class cvpmDictionary Private mDict Private Sub Class_Initialize : Set mDict = CreateObject("Scripting.Dictionary") : mDict("key") = "value" : End Sub Public Function Keys : Keys = mDict.Keys : End Function End Class
Dim vpDict Set vpDict = New cvpmDictionary
Sub RollingTimer_Timer For Each obj In vpDict.Keys : Debug.Print "Key" : Next End Sub
RollingTimer_Timer gets executed a few times a second. This seems to leak the vpDict.Keys SafeArray.
If I change the code to:
Sub RollingTimer_Timer Dim x x = vpDict.Keys For Each obj In x : Debug.Print "Key" : Next End Sub
No memory leaks are detected. In this case, release_exec calls VariantClear for ctx->vars which frees the SafeArray in X.
In the first case, vpDict.Keys doesn't appear to be stored anywhere, so nothing is freed in release_exec.