Click here to Skip to main content
15,884,388 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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


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.
Posted
Comments
Sergey Alexandrovich Kryukov 16-Apr-12 13:25pm    
Any special reason to deal with VB6? :-)
--SA
SuperMiQi 18-Apr-12 4:16am    
Hello SAKryukov,

Thank you for your reply but the project I have to maintain was developped on Visual Basic 6.

Have a nice day.
Best regards.
SuperMiQi

1 solution

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
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900