473,396 Members | 1,966 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

Releasing Object Variables

Can you post code, or a reference to a md? or ad? file on a website,
where object variables are not released when they go out of scope and
cause a problem, (but causing a problem is extraneous to this
question), other than these two:
DAO.Database
DAO.Recordset
?

To rephrase:
Can you demonstrate any situation where failure to
SET ObjectVariable = Nothing
causes a problem
other than
SET DB = Nothing
SET RS = Nothing
(RS is a DAO Recordset)
?

My applications are code heavy and my own personal choice is to use VBA
script and SQL script through ADO as preferences to any other method of
working. I do not use DAO explicitly. Over the past several years I
have not (as I remember) released any object variable by setting it to
nothing. TTBOMK this has caused zero problems. Perhaps, this is the
same number that setting object variables to nothing has caused you?

Nov 13 '05 #1
18 3681
Br
lylefair <ly******@yahoo.ca> wrote:
Can you post code, or a reference to a md? or ad? file on a website,
where object variables are not released when they go out of scope and
cause a problem, (but causing a problem is extraneous to this
question), other than these two:
DAO.Database
DAO.Recordset
?

To rephrase:
Can you demonstrate any situation where failure to
SET ObjectVariable = Nothing
causes a problem
other than
SET DB = Nothing
SET RS = Nothing
(RS is a DAO Recordset)
?

My applications are code heavy and my own personal choice is to use
VBA script and SQL script through ADO as preferences to any other
method of working. I do not use DAO explicitly. Over the past several
years I have not (as I remember) released any object variable by
setting it to nothing. TTBOMK this has caused zero problems. Perhaps,
this is the same number that setting object variables to nothing has
caused you?


Better to be safe than sorry eh? Tidy programming is tidy programming :)
--
regards,

Bradley

A Christian Response
http://www.pastornet.net.au/response
Nov 13 '05 #2
That's why I state that I believe in GOD.
If there really is a GOD, then he/she/it might fry my ass for eternity
if I deny GOD's existence.
With GOD, there are side benefits. One gets to destroy aboriginal
cultures, carry on war and terrorism, burn people at the stake (and
carry on torture in general), sodomize choir boys, prevent birth
control and contribute to the poverty and misery associated with such
prevention, control women and their bodies, prevent marriage of people
who love each other, live well and still feel good about oneself.
What are the side benefits to releasing object variables that don't
have to be released besides being able to impress others with "tidy
programming" and stating that "MOST CDMA regulars recommend ...."?

Nov 13 '05 #3
On 21 Jul 2005 05:54:51 -0700, "lylefair" <ly******@yahoo.ca> wrote:
Can you post code, or a reference to a md? or ad? file on a website,
where object variables are not released when they go out of scope and
cause a problem, (but causing a problem is extraneous to this
question), other than these two:
DAO.Database
DAO.Recordset
?


I can't post you a reference, but I can tell you that I had a serious problem
with that using the VBIDE library. The symptoms occurred for me in Access
2000, but not in 2002.

Nov 13 '05 #4
lylefair wrote:
That's why I state that I believe in GOD.
If there really is a GOD, then he/she/it might fry my ass for eternity
if I deny GOD's existence.
With GOD, there are side benefits. One gets to destroy aboriginal
cultures, carry on war and terrorism, burn people at the stake (and
carry on torture in general), sodomize choir boys, prevent birth
control and contribute to the poverty and misery associated with such
prevention, control women and their bodies, prevent marriage of people
who love each other, live well and still feel good about oneself.
What are the side benefits to releasing object variables that don't
have to be released besides being able to impress others with "tidy
programming" and stating that "MOST CDMA regulars recommend ...."?


I guess for me the fact that not releasing them has never caused you a
problem is not proof than not releasing them will never cause me a problem.
I have heard cases from others where it did and I have seen cases myself in
knock-off test files where Access would do the "minimize but don't close"
trick because I didn't clean up my objects properly. Assuming you are
correct and this only affects DAO objects since I DO use DAO I would have to
adopt a coding style where I explicitly release only "some of the time" and
that leads to mistakes.

When I code in Java or dot-net I don't explicitly tidy up so it's not a
matter of being "religious" about it.

--
I don't check the Email account attached
to this message. Send instead to...
RBrandt at Hunter dot com
Nov 13 '05 #5
On 21 Jul 2005 05:54:51 -0700, "lylefair" <ly******@yahoo.ca> wrote:
Can you post code, or a reference to a md? or ad? file on a website,
where object variables are not released when they go out of scope and
cause a problem, (but causing a problem is extraneous to this
question), other than these two:
DAO.Database
DAO.Recordset
?

.....

Conversley, I have often had problems with calling excel from access using automation
when I did explicitly set everything to nothing. There have been a number of SP
fixes for different versions here.

Nov 13 '05 #6
Bri


lylefair wrote:
Can you post code, or a reference to a md? or ad? file on a website,
where object variables are not released when they go out of scope and
cause a problem, (but causing a problem is extraneous to this
question), other than these two:
DAO.Database
DAO.Recordset
?

To rephrase:
Can you demonstrate any situation where failure to
SET ObjectVariable = Nothing
causes a problem
other than
SET DB = Nothing
SET RS = Nothing
(RS is a DAO Recordset)
?

My applications are code heavy and my own personal choice is to use VBA
script and SQL script through ADO as preferences to any other method of
working. I do not use DAO explicitly. Over the past several years I
have not (as I remember) released any object variable by setting it to
nothing. TTBOMK this has caused zero problems. Perhaps, this is the
same number that setting object variables to nothing has caused you?


I've had problems with Object variables used for Automation (eg. Word,
Excel, Outlook) and with Form variables. Most of the time the problem is
that Access won't Quit (minimizes only) and has to be killed in Task
Manager. Occasionally, I see crashes (used to be the Blue Screen, now
its the XP Send Info to MS dialog).

DB and RS are guaranteed to cause a problem if not released, the others
don't always fail so they be failing when combined with something else.

--
Bri

Nov 13 '05 #7
"lylefair" <ly******@yahoo.ca> wrote in
news:11**********************@g47g2000cwa.googlegr oups.com:
Can you post code, or a reference to a md? or ad? file on a
website, where object variables are not released when they go out
of scope and cause a problem, (but causing a problem is extraneous
to this question), other than these two:
DAO.Database
DAO.Recordset


I don't know of any. But I follow a principle given my MichKa, whose
judgment I trust, and that is to clean up any object variables that
are SET in code, or implicitly in For/Each statements.

I'm now considering adding WITH statements, but if I do that, the
benefit of a WITH over using an object variable disappears.

I suspect that:

For Each ctl In Me.Controls

is not going to create a problematic implicit reference, whereas
code called from elsewhere:

For Each ctl in Forms!MyForm.Controls

might run the risk of leaving an implicit variable.

Reference counting is inherently flawed as a cleanup method and
there could be any number of reasons why it will fail in some
contexts.

Identifying explicit and implicit object references is, I think, not
a bad thing for helping one fully understand one's own code, so I'm
not upset about the voodoo aspect of it.

The longer I'm involved in computers professionally, the less
rational running computers looks to me. The line that makes my
clients laugh is that I tell them to do whatever to their computer
and then to sacrifice two chickens and sprinkle the blood over the
PC. Sometimes the way these boxes behave really does look like it
was the chicken blood that fixed the problem.

--
David W. Fenton http://www.bway.net/~dfenton
dfenton at bway dot net http://www.bway.net/~dfassoc
Nov 13 '05 #8
foaming@themouth ((another) rude person) wrote in
news:42dfc572.201238065@localhost:
On 21 Jul 2005 05:54:51 -0700, "lylefair" <ly******@yahoo.ca>
wrote:
Can you post code, or a reference to a md? or ad? file on a
website, where object variables are not released when they go out
of scope and cause a problem, (but causing a problem is extraneous
to this question), other than these two:
DAO.Database
DAO.Recordset
?

....

Conversley, I have often had problems with calling excel from
access using automation when I did explicitly set everything to
nothing. There have been a number of SP fixes for different
versions here.


There the problems can be outside of Access. If you set your Excel
application object variable to nothing and don't do a .Quit
beforehand, you'll get an orphaned Excel process hanging out there
taking up memory.

It also illustrates why you should both close and set to Nothing,
because in the case of an outside application, there are two very
different memory structures, one internal and one entirely external
to Access (i.e., the Excel application).

On the other hand, I always felt it was pretty easy to understand
that setting to Nothing did not necessarily release the memory for
the object the variable pointed to. If you have a road sign that
says "New York City 58 miles" taking down the sign does not cause
NYC to cease to exist (however much many might wish it so).

--
David W. Fenton http://www.bway.net/~dfenton
dfenton at bway dot net http://www.bway.net/~dfassoc
Nov 13 '05 #9
On Thu, 21 Jul 2005 12:48:57 -0500, "David W. Fenton" <dX********@bway.net.invalid> wrote:
Conversley, I have often had problems with calling excel from
access using automation when I did explicitly set everything to
nothing. There have been a number of SP fixes for different
versions here.


There the problems can be outside of Access. If you set your Excel
application object variable to nothing and don't do a .Quit
beforehand, you'll get an orphaned Excel process hanging out there
taking up memory.


And even if you do everything you should you still get an orphan with some combinations
of Access and Excel, as various KB articles and threads in this group testify to.
I hate "Office automation" as no two users seem to have the same set up.

Nov 13 '05 #10
rkc
lylefair wrote:
That's why I state that I believe in GOD.
If there really is a GOD, then he/she/it might fry my ass for eternity
if I deny GOD's existence.
With GOD, there are side benefits. One gets to destroy aboriginal
cultures, carry on war and terrorism, burn people at the stake (and
carry on torture in general), sodomize choir boys, prevent birth
control and contribute to the poverty and misery associated with such
prevention, control women and their bodies, prevent marriage of people
who love each other, live well and still feel good about oneself.
What are the side benefits to releasing object variables that don't
have to be released besides being able to impress others with "tidy
programming" and stating that "MOST CDMA regulars recommend ...."?


You must be a real scream at parties.
Nov 13 '05 #11
Br
lylefair <ly******@yahoo.ca> wrote:
That's why I state that I believe in GOD.
If there really is a GOD, then he/she/it might fry my ass for eternity
if I deny GOD's existence.
With GOD, there are side benefits. One gets to destroy aboriginal
cultures, carry on war and terrorism, burn people at the stake (and
carry on torture in general), sodomize choir boys, prevent birth
control and contribute to the poverty and misery associated with such
prevention, control women and their bodies, prevent marriage of people
who love each other, live well and still feel good about oneself.
Rather pessamistic view IMO :)
What are the side benefits to releasing object variables that don't
have to be released besides being able to impress others with "tidy
programming" and stating that "MOST CDMA regulars recommend ...."?


--
regards,

Bradley

A Christian Response
http://www.pastornet.net.au/response
Nov 13 '05 #12
smiling@adversity (polite person) wrote in
news:42dfe5b8.209498112@localhost:
On Thu, 21 Jul 2005 12:48:57 -0500, "David W. Fenton"
<dX********@bway.net.invalid> wrote:
Conversley, I have often had problems with calling excel from
access using automation when I did explicitly set everything to
nothing. There have been a number of SP fixes for different
versions here.


There the problems can be outside of Access. If you set your Excel
application object variable to nothing and don't do a .Quit
beforehand, you'll get an orphaned Excel process hanging out there
taking up memory.


And even if you do everything you should you still get an orphan
with some combinations of Access and Excel, as various KB
articles and threads in this group testify to. I hate "Office
automation" as no two users seem to have the same set up.


I know of plenty of ways to get orphan processes, but I also know of
the right way to avoid it.

If you're getting orphaned processes, then your doing your
automation wrong, seems to me.

--
David W. Fenton http://www.bway.net/~dfenton
dfenton at bway dot net http://www.bway.net/~dfassoc
Nov 13 '05 #13
rkc wrote:
You must be a real scream at parties.


I'm very good in "Spin The Bottle".

Nov 13 '05 #14

"rkc" <rk*@rochester.yabba.dabba.do.rr.bomb> wrote in message
news:Ya*******************@twister.nyroc.rr.com...
lylefair wrote:
That's why I state that I believe in GOD.
If there really is a GOD, then he/she/it might fry my ass for eternity
if I deny GOD's existence.
With GOD, there are side benefits. One gets to destroy aboriginal
cultures, carry on war and terrorism, burn people at the stake (and
carry on torture in general), sodomize choir boys, prevent birth
control and contribute to the poverty and misery associated with such
prevention, control women and their bodies, prevent marriage of people
who love each other, live well and still feel good about oneself.
What are the side benefits to releasing object variables that don't
have to be released besides being able to impress others with "tidy
programming" and stating that "MOST CDMA regulars recommend ...."?


You must be a real scream at parties.

He's just upset because he was born with low intelligence.

PA
South Carolina

Nov 13 '05 #15
Br
lylefair <ly******@yahoo.ca> wrote:
http://www.triplenine.org


IQ tests aren't always a good indicator of intelligence... and least of
all personality ;)
--
regards,

Bradley

A Christian Response
http://www.pastornet.net.au/response
Nov 13 '05 #17
On Thu, 21 Jul 2005 19:44:35 -0500, "David W. Fenton" <dX********@bway.net.invalid> wrote:

And even if you do everything you should you still get an orphan
with some combinations of Access and Excel, as various KB
articles and threads in this group testify to. I hate "Office
automation" as no two users seem to have the same set up.


I know of plenty of ways to get orphan processes, but I also know of
the right way to avoid it.

If you're getting orphaned processes, then your doing your
automation wrong, seems to me.

--

Now you are being patronising. I said that some versions will give you errors,
which is true. If you have control of your users machines you can avoid this.
Nov 13 '05 #18
not@all (polite person) wrote in news:42e09f49.257003301@localhost:
On Thu, 21 Jul 2005 19:44:35 -0500, "David W. Fenton"
<dX********@bway.net.invalid> wrote:

And even if you do everything you should you still get an
orphan with some combinations of Access and Excel, as various
KB articles and threads in this group testify to. I hate "Office
automation" as no two users seem to have the same set up.


I know of plenty of ways to get orphan processes, but I also know
of the right way to avoid it.

If you're getting orphaned processes, then your doing your
automation wrong, seems to me.

Now you are being patronising. I said that some versions will give
you errors, which is true. If you have control of your users
machines you can avoid this.


I've never seen it.

Of course, I never use anything but late binding. Perhaps that's why
I've never encountered the problems you're alluding to.

If so, then, we're in a loop.

--
David W. Fenton http://www.bway.net/~dfenton
dfenton at bway dot net http://www.bway.net/~dfassoc
Nov 13 '05 #19

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

Similar topics

4
by: lebo | last post by:
Hi I'm trying to understand how Python handles memory usage and dynamic object loading and unloading. Problem to solve? Build a very low memory footprint (non-GUI) Python application for...
2
by: sausage31 | last post by:
I'm exporting some data to excel but am having trouble getting Access to 'release' Excel. What i want to achieve is to open excel, export some data then leave excel open so that the user can...
2
by: M.Ob | last post by:
Hello... I am having issues with my asp.net apps not releasing memory. The memory usage for the process w3p.exe continues to grow to it's allowable limit and does not drop until the app pool is...
5
by: Mark Rae | last post by:
Hi, I'm encountering a strange phenomenon whereby a DataSet object is not releasing its memory when it's being disposed and/or set to Nothing. It is part of a Windows service written in VB.NET...
2
by: B.N.Prabhu | last post by:
In my web application(C#) . I am adding one excel sheet and then save and closing that excel file. In the finally bloack i gave Marshal.ReleaseComObject(clsExcel); But when i go and see in the...
12
by: iker.arizmendi | last post by:
Is there any way to get Python to release memory back to the C allocator? I'm currently running a script that goes through the following steps: 1) Creates a very large number of Python objects...
0
by: Matti Airas | last post by:
Hi all, I've been toying with an idea of dependency-based coding, in which you construct a graph of code dependencies. Say, you have independent variables 'a' and 'b', and a function f(x,y)....
0
by: 062699 | last post by:
Hi All, Thank you in advance. I am having trouble releasing resources when I open a child form. Please see the code below. Form f; private void button1_Click(object sender, EventArgs e) { ...
3
by: ssylee | last post by:
For example, I have a BITMAPINFO* and a BYTE* object to release the resources. Would the most bulletproof way of doing so involve checking to see if they are null, then if they are not, invoke a...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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,...
0
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...
0
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...
0
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...
0
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,...

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.