Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: VB6 COM memory
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 13-Apr-12 0:50am
Comments
SAKryukov at 16-Apr-12 13:25pm
   
Any special reason to deal with VB6? :-)
--SA
SuperMiQi at 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

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

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
  Permalink  

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



Advertise | Privacy | Mobile
Web02 | 2.8.140926.1 | Last Updated 27 May 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100