473,659 Members | 2,488 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Dynamic ActiveX controls memory leak (URGENT)

2 New Member
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_Ini tialize 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 RemoveMeasureme nt 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 2796
LintDiggy
2 New Member
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
6787
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 access it I have an InvalidActiveXState Exception. I cannot find mutch on the web about this Invalid State of a component except that it is invalid (what the Exception already describe). So I hope someone here knows ?
4
2512
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 usual way? If yes, may you provide a hint/link for getting started? Best regards,
1
4887
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 another page in the same domain which also contains infragistics datagid populated with default data retrieved from Data Base. After creating the frame I am attaching it to the HTML DOM and show it as modal popup with OK and Cancel Button inside an...
22
9332
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 memory leak someplace. I can not detect the memory leak by running several reports by hand, but when I run tha app as a servrice and process few hundred reports there is significant memory leak. The application can consume over 1GB of memory where it...
0
8428
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8851
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8539
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8630
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
5650
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4176
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4342
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2759
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1982
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.