Re: Releasing Object Variables



"lylefair" <lylefair@xxxxxxxx> wrote in
news:1121950491.487212.132420@xxxxxxxxxxxxxxxxxxxxxxxxxxxx:

> 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
.



Relevant Pages

  • Re: Anders Hejlsberg comment on immutable objects
    ... >explicit interface implementation exists is so an interface name can class ... Improper implicit conversions constitute a nasty ... >> With value types, the variable's value is the object, not a reference ... Consider the affects of our different views on a const ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: how to find union of two arrays
    ... "memory and system resources associated ... I believe that says that non-static local object variables are ... returning from testit2, and use Task Manager to show that the memory ... That could only happen if the reference count for the object went to ...
    (microsoft.public.excel.programming)
  • Re: Assumed-shape arrays and dummy procedures
    ... "If the interface of the dummy argument is implicit and either the ... a reference of the actual argument procedure. ... lies in subroutine C, and here the program really is nonconforming, ...
    (comp.lang.fortran)
  • Re: Nothing Keyword Destories Objects rather than just resetting the variable to an empty variable
    ... undesired effect of the ByRef). ... cause of the local object variable of C was reference to the same ... Yes, an object variable is a pointer to an object, but that is the only ... Though I haven't fully tested it to be sure with object variables, ...
    (microsoft.public.excel.programming)
  • Re: f77 errors
    ... IMPLICIT NONE ... Invalid declaration of or reference to symbol `matrixmult' at ...
    (comp.lang.fortran)