473,666 Members | 1,977 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Disposing Object in VB 6.0

Hi all,

I'm just wondering that is any way to dispose all objects when my app is
shut down? I mean I can use for.. next loop to unload all loaded form when I
shut down my app.

Thank you,

Egghead
Jul 17 '05 #1
1 5993
As a general rule, you only need to close system resources that you opened.
These are timers, sockets, files, etc., although the VB 6 runtime does a
pretty good job of this for you. Any object that is left at application
shutdown will have it's terminate event fired and the object will be
reclaimed by the system. To see if your application is correctly shutdown,
check the task manager (Ctrl-Shift-Esc) processes tab to see if it
disappears.

During runtime, VB 6 has a reference counting Garbage Collectors. Objects
are destroyed when their reference count goes to zero, which can occur in
one of three ways. Reference counts are decremented when an object is set
to Nothing, when it goes out of scope, or when a parent object's reference
count goes to zero. Thus setting a collection of objects to nothing will
decrement the reference count for each of the objects in the collection if
there are no other references to the collection.

As part of the application cleanup, the VB 6 runtime zeros and the
references of any objects left in memory and the terminate events will fire
at that time.

Mike Ober.

"Egghead" <ro******@shaw. ca> wrote in message
news:aFn%d.7448 21$6l.191574@pd 7tw2no...
Hi all,

I'm just wondering that is any way to dispose all objects when my app is
shut down? I mean I can use for.. next loop to unload all loaded form when I shut down my app.

Thank you,

Egghead


Jul 17 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

15
3727
by: Chris Capel | last post by:
I've heard a lot of talk on the forum about memory managment in .NET and disposing things, finalizing them, garbage collection, etc. My question is which managed types need to be disposed after being used, and for which is it OK to simply let the garbage collector do its work, without worrying about calling Dispose? Is there a general rule that most don't need to be explicitly disposed, with an exception here and there? Or the other way...
4
1478
by: MC D | last post by:
Question: If I have a class which has a property which is a collection of widget objects (an arrayList of widgets), and both the containter class and the widget class implement the IDisposable interface, does the container class need to call the dispose method of each of the widgets when its dispose method is called, or does this happen automatically because the container class will go "out of scope"? Thanks for any help!
13
4246
by: MuZZy | last post by:
Hi, Just wanted to make sure i get it right: consider this class: // =========== START CODE ============= class Test { private SqlConnection con = null; public void Connect() { con = new SqlConnection(SomeConnectionString);
4
1384
by: sunitabalakrishna | last post by:
Hi, Could someone explain me if I need to implement the Dispose pattern on managed objects that hold objects which have longer life or is a singleton? Example - Class A holds Class Global where Class Global is a singleton. So should Class A have
5
1516
by: Chris | last post by:
I have a form that requires drawing custom lines on it. The color of the lines is suppose to be the same as the forcolor of the form. Am I doing this the most efficent and correct way? Thanks.... Protected mPen As Pen Protected Overrides Sub OnPaint(ByVal e As System.Windows.Forms.PaintEventArgs) MyBase.OnPaint(e) If mPen Is Nothing Then mPen = New Pen(Me.ForeColor)
10
3935
by: sternr | last post by:
Hey, I have a C# assembly that inherits from ServicedComponent and is installed in the Com+ with ServerActivation. And I have a C++ application that calls this Com+ object successfully, But the problem is that I cant seem to dispose the object! I tried calling the following code: myComPlus->Release(); myComPlus = NULL; delete myComPlus;
0
1521
by: Gman | last post by:
Hi, Objective: Draw a grid on a bitmap and set this as a panel's image. (Rather than draw the grid directly on the panel and redraw repeatedly in the paint event.) Problem: It works fine. I'm just not sure about disposing of the objects. I've tried a variety of approaches but I find that when I redraw repeatedly
4
1390
by: Rob | last post by:
Hi all, I wrote myself a little function to do my own housekeeping, I can call it by using Dispose(object) Within this function there's a select case statement which will then, based on some flags and the type of the object do things like close connections, dispose of the object where appropriate and so on.
8
8988
by: Varangian | last post by:
Hello, was wondering of how to dispose of managed resources? or referencing every member of a class to null will release resources...? http://www.marcclifton.com/tabid/79/Default.aspx http://www.codeproject.com/managedcpp/garbage_collection.asp - sources
29
2366
by: Jerry Spence1 | last post by:
I'm rather confused as to whether something should be disposed of, or not. What is the general rule? How can you be sure of doing the right thing? I've heard about disposing unmanaged resources but what is an unmanaged resource? Does everything need disposing? I've been using Webrequest, Webresponse, Streamreaders etc. How can I be sure of what needs disposing? Do these get automatically get disposed of at the end of the procedure...
0
8356
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8871
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...
0
8781
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8551
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
7386
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5664
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
4198
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...
1
2771
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
2011
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.