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.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...
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!@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.
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.In any event I will place you on my ignore list.
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.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.
![]()
When Are You Required To Set Objects To Nothing?
learn.microsoft.com
Is Manual Memory Management Necessary in Modern Day Access? When Does Garbage Collection Occur?
Hi all, I was wondering if I could get some of your opinions on whether explicit memory management in VBA code is a good practice / necessary in modern day VBA. Here's my current understanding, please correct me where I'm wrong. When an object, such as a recordset, goes out of scope, that is...www.access-programmers.co.uk
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.
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.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.
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.Well, isn't it a form of garbage collection?
The thread on "garbage collection on VBA" is up there now.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.
Except I gave you that cool code that fixes a broken seed.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.
And THAT was cool!Except I gave you that cool code that fixes a broken seed.
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.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.
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.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.
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.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.