OpenArgs (my) class way (7 Viewers)

JFTR: VBA does not have garbage collection. Memory for object variables is released based on COM reference counting.
 
I thought so. But I usually iterate and destroy all the items before destroying the container object. After all, if we really trusted the garbage collector, we wouldn't even consider destroying the container object...
No you do not. You do not destroy anything. All you are doing is releasing a pointer. But if this makes you feel better continuing doing it.

If you believe that VBA does not have a trusted clean up, I say prove it.
All this discussion about setting objects to Nothing is usually a complete waste of time. What you think you are doing is not really doing anything. You are simply releasing a pointer. You are not triggering "garbage collection" or memory clean up. VBA takes care of that.

There are times to close open connections and there are a few times to set objects to nothing. But you are really better off understanding the exceptions instead of thinking you are doing something by setting everything to nothing. At the most I set objects to nothing 1% of the time, but it is for a specific reason. Some of this is described here.



People find it easier to just set all objects to nothing based on an urban myth, than trying to understand when and why.

You can disagree with this, and again I say prove it. Show some cases where the code fails when not setting something to nothing. I can demonstrate some of those cases.

I the last twenty years of actively posting stuff on forums, I am sure I have posted 100 of thousands of lines of vba code, 1000s of example dbs, 100s of class modules and rarely if ever set an object to nothing. Only once did someone come back and say the code failed. And this case falls into one of those exact cases explained in the article that I should have taken care of. So I guess I should have set about 100 thousand other variables to nothing just to catch this one case.
 
Last edited:
@jwcolby54 I guess your openargs class only replicates the built in functionality since you haven't been able to provide any reason I might want to invest the time to use it.
 
@jwcolby54 I guess your openargs class only replicates the built in functionality since you haven't been able to provide any reason I might want to invest the time to use it.
LOL, it is not my job to provide any reason for you to invest the time to use it. We all tread the path we tread on this earth. I have explained in some detail what a framework is, what mine does, and how this specific tiny little part of my framework contributes to the whole. You apparently have no interest in such things. You are intentionally baiting it seems. You are you and I am, thankfully, not. A little baiting of my own! :ROFLMAO:

In any event I will place you on my ignore list.

If I can figure out how to do that.
 
In any event I will place you on my ignore list.
Good move since you are no teacher. Teachers always answer honest questions respectfully. Just FYI. No novice is following this conversation and the experts all know what a framework is and all of them practice strong design principles but thanks for the lesson anyway.

My takeaway is - your openargs class adds nothing to Access that doesn't already exist.
 
No you do not. You do not destroy anything. All you are doing is releasing a pointer. But if this makes you feel better continuing doing it.

If you believe that VBA does not have a trusted clean up, I say prove it.
All this discussion about setting objects to Nothing is usually a complete waste of time. What you think you are doing is not really doing anything. You are simply releasing a pointer. You are not triggering "garbage collection" or memory clean up. VBA takes care of that.

There are times to close open connections and there are a few times to set objects to nothing. But you are really better off understanding the exceptions instead of thinking you are doing something by setting everything to nothing. At the most I set objects to nothing 1% of the time, but it is for a specific reason. Some of this is described here.



People find it easier to just set all objects to nothing based on an urban myth, than trying to understand when and why.

You can disagree with this, and again I say prove it. Show some cases where the code fails when not setting something to nothing. I can demonstrate some of those cases.

I the last twenty years of actively posting stuff on forums, I am sure I have posted 100 of thousands of lines of vba code, 1000s of example dbs, 100s of class modules and rarely if ever set an object to nothing. Only once did someone come back and say the code failed. And this case falls into one of those exact cases explained in the article that I should have taken care of. So I guess I should have set about 100 thousand other variables to nothing just to catch this one case.
Funny you should mention that. I understand "last pointer" thing but IMO the vast majority of devs do not. The man asked a simple question, I gave a simple answer. I am (or more correctly was) deep into classes and frameworks, where objects loaded other objects, kept pointers to forms, passed those pointers (and others) into the classes they were opening. I absolutely did have issues when I didn't intentionally clean things up. I had forms not closing. I had Access not closing because something was hanging out that the Access couldn't shut down. Not setting that "last pointer" to nothing can and does cause issues. And so I do, intentionally, with malice and forethought, religiously clean up behind myself.

And if you don't, or think I am silly... <shrug> It's sad there is no shrug emoji. I thought I had seen one.

In any event I was just in the process of starting a thread about the so called garbage collector in VBA. It is not easy to get it all pasted in, and keep the
Code:
thing around everything. But I am trying!

I expect a lively discussion. I probably will not participate since this is just an academic interest to me, and at the moment I am doing other things.
 
Good move since you are no teacher. Teachers always answer honest questions respectfully. Just FYI. No novice is following this conversation and the experts all know what a framework is and all of them practice strong design principles but thanks for the lesson anyway.

My takeaway is - your openargs class adds nothing to Access that doesn't already exist.
Now do me a favor and (since you are such a great instructor) tell me how to ignore your posts?
 
Good move since you are no teacher. Teachers always answer honest questions respectfully. Just FYI. No novice is following this conversation and the experts all know what a framework is and all of them practice strong design principles but thanks for the lesson anyway.

My takeaway is - your openargs class adds nothing to Access that doesn't already exist.
533 views as of this instant. But hey. I have no metrics to tell me how many of those views are novices etc, or who follows things.

And you are right I am no teacher. I have answered you same "issue" over and over and you either don't understand or choose not to understand.

In the end I am just a guy who was unfortunate enough to run into and annoy you in my threads:sick:. It has been mildly amusing if nothing else. And it has been, mostly, nothing else.

You are an "acknowledged expert" (and yes @NauticalGent I am using the quotes intentionally) here but TBH you haven't contributed anything useful to my threads. EVER that I can remember.

Are we having fun yet?
 
Well, isn't it a form of garbage collection?
I am setting up a discussion on how VBA's garbage collection works. Is it a "garbage collector"? Who really cares. What does that really mean? Such an existential discussion we launch into. In the end it takes care of releasing the memory used for our objects when we release them. The generic term for that is garbage collection.
 
I am setting up a discussion on how VBA's garbage collection works. Is it a "garbage collector"? Who really cares. What does that really mean? Such an existential discussion we launch into. In the end it takes care of releasing the memory used for our objects when we release them. The generic term for that is garbage collection.
The thread on "garbage collection on VBA" is up there now.
 
You are an "acknowledged expert" (and yes @NauticalGent I am using the quotes intentionally) here but TBH you haven't contributed anything useful to my threads. EVER that I can remember.
Except I gave you that cool code that fixes a broken seed.
 
No you do not. You do not destroy anything. All you are doing is releasing a pointer. But if this makes you feel better continuing doing it.

If you believe that VBA does not have a trusted clean up, I say prove it.
All this discussion about setting objects to Nothing is usually a complete waste of time. What you think you are doing is not really doing anything. You are simply releasing a pointer. You are not triggering "garbage collection" or memory clean up. VBA takes care of that.

There are times to close open connections and there are a few times to set objects to nothing. But you are really better off understanding the exceptions instead of thinking you are doing something by setting everything to nothing. At the most I set objects to nothing 1% of the time, but it is for a specific reason. Some of this is described here.

People find it easier to just set all objects to nothing based on an urban myth, than trying to understand when and why.

You can disagree with this, and again I say prove it. Show some cases where the code fails when not setting something to nothing. I can demonstrate some of those cases.

I the last twenty years of actively posting stuff on forums, I am sure I have posted 100 of thousands of lines of vba code, 1000s of example dbs, 100s of class modules and rarely if ever set an object to nothing. Only once did someone come back and say the code failed. And this case falls into one of those exact cases explained in the article that I should have taken care of. So I guess I should have set about 100 thousand other variables to nothing just to catch this one case.
Thanks for contributing to the discussion. I perfectly know I don't "destroy" anything, and it's just a pointer release. "Destroy" is just a word I often use in place of "releasing a pointer" because I find it more satisfying, and I'm sorry if you felt offended by that. Are you a member of some radical association against the use of "set to nothing"? Otherwise, I can't explain such vehemence against a habit of mine that, in the worst case scenario, has no consequence and doesn't hurt anyone. More specifically - yes, it occurred to me in the past. I had malfunctionings and, in a few cases, a crash of the application because I didn't destroy - sorry, released the pointers of - some objects. Can I prove it? Of course not, I can't recreate the exact scenario. Perhaps I could prove it using Windows objects like timers, but I don't feel like spending time on such a minor issue. And I don't see no reason to abandon this habit, which takes me literally seconds, just to risk another disaster which would take me hours to debug and solve. It's called "preventive programming". Is it useless, a waste of time? Yes, maybe, I agree. But it's MY developing time we're talking about, it doesn't harm, and certainly doesn't deserve such a rude reaction.
 
Otherwise, I can't explain such vehemence against a habit of mine that, in the worst case scenario, has no consequence and doesn't hurt anyone. More specifically - yes, it occurred to me in the past. I had malfunctionings and, in a few cases, a crash of the application because I didn't destroy - sorry, released the pointers of - some objects. Can I prove it? Of course not, I can't recreate the exact scenario.
Sorry if my rant seemed directed to you, it was not meant to be. It really to all the other people that repeat this information and state that setting objects to nothing is a requirement and the the solution for all our coding ills. Trust me you will see it on this site often. As I said if someone wants to wear belts and suspenders and it makes them feel better than have at it.

I will not tell a novice user that is the solution. I will tell them to try to learn when you set objects to nothing and when not to. (Circular references, implicit circular references, etc). There are also similar social myths I see people repeat with these blanket solutions instead of understanding the real issue.

But I do have an issue (because there are a lot of novice users reading things on this site that are influenced with what you post) when people propagate myths. When people suggest things like Access does not have trusted "garbage clean up" and therefore setting every object to nothing is something we should be doing. Or that somehow they are "cleaning up" after themselves where in other languages this does have a meaning.
 
I still don't see your point. Releasing pinters takes seconds. Trying to avoid/looking for circular references, implicit circular references etc. can take A LOT of time and experience. What's the added value in it? What's SO wrong in setting a pointer to nothing?
 
Sorry if my rant seemed directed to you, it was not meant to be. It really to all the other people that repeat this information and state that setting objects to nothing is a requirement and the the solution for all our coding ills. Trust me you will see it on this site often. As I said if someone wants to wear belts and suspenders and it makes them feel better than have at it.

I will not tell a novice user that is the solution. I will tell them to try to learn when you set objects to nothing and when not to. (Circular references, implicit circular references, etc). There are also similar social myths I see people repeat with these blanket solutions instead of understanding the real issue.

But I do have an issue (because there are a lot of novice users reading things on this site that are influenced with what you post) when people propagate myths. When people suggest things like Access does not have trusted "garbage clean up" and therefore setting every object to nothing is something we should be doing. Or that somehow they are "cleaning up" after themselves where in other languages this does have a meaning.
The issue with this is that it does take a lot of experience, which you absolutely have (but the novice absolutely does not have), to actually know when it will cause an issue and when it won't and if you get it wrong things do not work right, and trying to figure out why things are not working right can take a lot of time. Or in fact for the novice they may never figure out what is going wrong.

So while you are technically correct, and you are technically correct, just cleaning up each and every pointer to every object dimensioned takes little time and absolutely can and does prevent some issue some where. Further, classes give us the close event specifically for the purpose of performing cleanup, which strongly implies that MS encourages this practice. It is accepted practice by the vast majority of even expert developers, myself included, to just clean up behind myself. In fact it is accepted practice in pretty much every language environment!

And so I absolutely do that. Because I have so many classes just instantiated and destroyed automatically, passing pointers to objects back and forth, using WithEvents routinely, I absolutely have run into this very problem and figuring out why was an absolute nightmare. And I do know the why of what I am doing!

And... I have no problem with you (and I) teaching what is behind this practice, what we are actually fixing when we do this. Knowledge is a good thing.
 
Last edited:

Users who are viewing this thread

Back
Top Bottom