内存未使用VB6释放 [英] Memory not released using VB6

查看:113
本文介绍了内存未使用VB6释放的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我在Visual Basic 6上遇到以下问题.

在默认的vb程序项目中,按钮事件处理程序中包含以下几行:

Hello Everyone,

I have the following issue on Visual Basic 6.

In a default vb program project, I have the following lines in a button event handler:

Private Sub Command1_Click()
    On Error Resume Next
    
    Dim Ws As Object
    Dim CloneMeas As Object
    Dim CloneSubMeas As Object
    Dim lMeas As Long
    Dim lSubMeas As Long
    
    Set Ws = CreateObject("mm_office.workspace")
    For lMeas = 1 To 8
        Set CloneMeas = CreateObject("mm_office.measurement")
        CloneMeas.Size = 1025
        CloneMeas.Complex = True

        For lSubMeas = 1 To 250
            Set CloneSubMeas = CreateObject("mm_office.measurement")
            CloneSubMeas.Size = 1025
            CloneSubMeas.Complex = True
            CloneMeas.measurements.Add CloneSubMeas
            Set CloneSubMeas = Nothing
        Next lSubMeas
        Ws.measurements.Add CloneMeas
        Set coSubMeass = Nothing
        Set CloneMeas = Nothing
    Next lMeas
    
    MsgBox CStr(Ws.measurements.Count)
    Ws.measurements.Removeall
       
    MsgBox CStr(Ws.measurements.Count)
    Set Ws = Nothing
End Sub



调用的对象在c ++ vs6中实现.

当我从vs6运行应用程序时,"Ws.measurements.Removeall"之后的内存返回到其初始状态.
如果我在编译版本中运行它,那么我将发生大约5 mb的内存泄漏.
可能是什么原因 ?我还没有看到内存泄漏,如果我运行一个示例c ++消费者应用程序,它可以正常工作.

真是疯了.

你已经看过类似的东西了吗?你可以给我什么样的建议?

提前非常感谢您.
最好的问候.
SuperMiQi.



The objects invoked are implemented in c++ vs6.

When I run the application from vs6, the memory after "Ws.measurements.Removeall" returns to his initial state.
If I run it in compiled version, I then get around 5 mb memory leakage.
What could be the reason ? I have not seen memory leakage and if I run a sample c++ consumer application, it works fine.

This is really crazy.

Do you have already seen something like that? What kind of advise could you post me ?

Thank you very much in advance.
Best regards.
SuperMiQi.

推荐答案

我相信,以下几行是您问题的基础:
CloneMeas.measurements.Add CloneSubMeas
设置CloneSubMeas = Nothing

尽管clonesubmeas首先已添加到测量中,但它没有设置为

每个vb对象都有一个参考计数器,当它再次变为0时,它将释放该对象,我相信原因是它们在测量中没有释放,对于下一个代码的计数相同:
Ws.measurements.添加CloneMeas
i believe, the following lines are base of your problem:
CloneMeas.measurements.Add CloneSubMeas
Set CloneSubMeas = Nothing

clonesubmeas is set to nothing, though it firstly has been added to measurements

Each vb object has a reference counter and when it becomes 0 again it will free the object, i believe cause they''re in measurements they are not freed, sames counts for the next code:
Ws.measurements.Add CloneMeas


这篇关于内存未使用VB6释放的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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