472,981 Members | 1,462 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,981 software developers and data experts.

Dynamic ActiveX controls memory leak (URGENT)

My vb6 application has a nasty memory leak that I can't trace for the life of me. I have an ActiveX object that I've created called an Operation. The control has the following components :

Picturebox (x3)
Label (x4)
TextBox (x2)
ListBox
ScrollBar
CommonDialog
ImageList
Timer

In code, the control has the following member Objects:

m_AllVersions As Collection
m_ModulePaths As Collection
m_Parameters As Collection
m_Measurements As Collection

In my UserControl_Initialize routine, I have a bunch of lines that set flags, configure the various texboxes and things, and I set each Collection to a New one. Nothing very fancy. I put a Debug.Print statement in to let me know that the Object has been created.

verbatem, here is my terminate method:
Expand|Select|Wrap|Line Numbers
  1. Private Sub UserControl_Terminate()
  2.  
  3.     'remove references to objects
  4.     Set m_AllVersions = Nothing
  5.     Set m_ModulePaths = Nothing
  6.     Set m_Parameters = Nothing
  7.     Set m_Measurements = Nothing
  8.  
  9.     Debug.Print vbTab & "OPERATION DESTROYED!!"
  10.  
  11. End Sub
  12.  
These Operation Objects are created dynamically when needed, so I have a method to create and destroy them from within another ActiveX control called a Module

Expand|Select|Wrap|Line Numbers
  1. Friend Function CreateOperation() As Operation
  2.  
  3.     Dim Opn As Operation
  4.     Static ControlIndex As Integer
  5.  
  6.     Set Opn = Controls.Add("Project1.Operation", "Module" & m_ControlIndex _
  7.         & "Operation" & ControlIndex)
  8.  
  9.     Opn.Move 0, 0, Extender.Width, Extender.Height
  10.     Opn.ControlIndex = ControlIndex
  11.  
  12.     ControlIndex = ControlIndex + 1
  13.     Set CreateOperation = Opn
  14.  
  15. End Function
  16.  
  17. Friend Sub DestroyOperation(ByRef Opn As Operation)
  18.  
  19.     Dim Index As Integer
  20.  
  21.     'explicitly remove reference to Operation in
  22.     '   all Parameter objects
  23.     For Index = 0 To Opn.ParamCount - 1
  24.  
  25.         Opn.RemoveParameter 0
  26.  
  27.     Next
  28.  
  29.     'explicitly remove reference to Operation in
  30.     '   all Measurement Objects
  31.     For Index = 0 To Opn.MeasCount - 1
  32.  
  33.         Opn.RemoveMeasurement 0
  34.  
  35.     Next
  36.  
  37.     'Remove Operation object from Controls Collection
  38.     Controls.Remove "Module" & m_ControlIndex & "Operation" & Opn.ControlIndex
  39.     Set Opn = Nothing
  40.  
  41. End Sub
  42.  
  43.  
Pay no attention to the RemoveParameter and RemoveMeasurement lines, Opn.ParamCount and Opn.MeasCount are 0 for testing.

Okay, so to test that everything is working, I just create and destroy the Operation Objects in a loop:

Expand|Select|Wrap|Line Numbers
  1. Dim i As Integer
  2. Dim Opn As Operation
  3.  
  4. For i = 1 To 1000
  5.  
  6.      Debug.Print "CREATING OPERATION " & i
  7.      Set Opn = Modl.CreateOperation
  8.      Modl.DestroyOperation Opn
  9.      Set Opn = Nothing
  10.  
  11. Next
  12.  
When I execute this, I get messages in the Immediate window letting me know that the objects are being created and destroyed, but after about 342 times through the loop, I get an Error - 7 Out of Memory.

Any ideas? Is there something unique about ActiveX objects that prevents them from being returned to memory properly?
Oct 9 '06 #1
1 2767
I don't know if this will help trace the problem, but it looks like something is going on inside the VB6 Developer environment.

As I said in the previous post, when I simply create and destroy 1000 of the Operation Objects, the debugger crashes and gives me the Out of Memory error.

However, when I open a project that has the ActiveX project as a reference, it is able to create all 1000 Operation Objects and destroy them without complaining.

Is there something I'm missing in the developer environment?
Oct 9 '06 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: Wilfried Mestdagh | last post by:
Hi, I have a C# application (VS2005) with Microsoft Mappoint activeX control on a form. At a certain moment I want to create a second one temporary in code. This seems not to work, when I try to...
4
by: Henrik Dahl | last post by:
Hello! Is it possible to use Visual Studio 2005 or, secondarily, Visual Studio .NET 2003 to create ActiveX controls which may be consumed by VB 6.0 programs, i.e. dealt with on forms in the...
1
by: cdmsenthil | last post by:
I have an Infragistics UltrawebGrid . Each Row in the grid is attached to a context menu using Infragistics CSOM Upon click on the menu, I am creating an Iframe dynamically which points to...
22
by: Peter | last post by:
I am using VS2008. I have a Windows Service application which creates Crystal Reports. This is a multi theaded application which can run several reports at one time. My problem - there is a...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...
0
by: Aliciasmith | last post by:
In an age dominated by smartphones, having a mobile app for your business is no longer an option; it's a necessity. Whether you're a startup or an established enterprise, finding the right mobile app...
0
tracyyun
by: tracyyun | last post by:
Hello everyone, I have a question and would like some advice on network connectivity. I have one computer connected to my router via WiFi, but I have two other computers that I want to be able to...
2
by: giovanniandrean | last post by:
The energy model is structured as follows and uses excel sheets to give input data: 1-Utility.py contains all the functions needed to calculate the variables and other minor things (mentions...
1
by: Teri B | last post by:
Hi, I have created a sub-form Roles. In my course form the user selects the roles assigned to the course. 0ne-to-many. One course many roles. Then I created a report based on the Course form and...
3
by: nia12 | last post by:
Hi there, I am very new to Access so apologies if any of this is obvious/not clear. I am creating a data collection tool for health care employees to complete. It consists of a number of...
0
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be focusing on the Report (clsReport) class. This simply handles making the calling Form invisible until all of the Reports opened by it have been closed, when it...
0
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.