Home All Groups Group Topic Archive Search About

destroying/releasing objects from memory?

Author
8 Dec 2006 8:41 PM
Rich
Greetings,

In a button on a form I instantiate 4 class objects.  Then, depending on
some other selections (radio buttons) on the form, I call a procedure from
one of the classes. Then I set all 4 classes equal to nothing to release them
from memory/destroy them.

Sub btn_Click(....) handles btn.Click
obj1 = new cls1
obj2 = new cls2
....
obj1 = nothing
obj2 = notihng
....
End Sub

Is this the correct way to release destroy an object for garbage collection?
(VB2005).

Thanks,
Rich

Author
8 Dec 2006 9:59 PM
Herfried K. Wagner [MVP]
Show quote Hide quote
"Rich" <R***@discussions.microsoft.com> schrieb:
> In a button on a form I instantiate 4 class objects.  Then, depending on
> some other selections (radio buttons) on the form, I call a procedure from
> one of the classes. Then I set all 4 classes equal to nothing to release
> them
> from memory/destroy them.
>
> Sub btn_Click(....) handles btn.Click
> obj1 = new cls1
> obj2 = new cls2
> ...
> obj1 = nothing
> obj2 = notihng
> ...
> End Sub
>
> Is this the correct way to release destroy an object for garbage
> collection?
> (VB2005).

No.  You do not need set the variables to 'Nothing' at the end of the method
because this is done automatically.

--
M S   Herfried K. Wagner
M V P  <URL:http://dotnet.mvps.org/>
V B   <URL:http://dotnet.mvps.org/dotnet/faqs/>
Author
8 Dec 2006 11:00 PM
Lucian Wischik
"Herfried K. Wagner [MVP]" <hirf-spam-me-here@gmx.at> wrote:
>> Sub btn_Click(....) handles btn.Click
>> obj1 = new cls1
>> obj2 = new cls2
>> ...
>> obj1 = nothing
>> obj2 = notihng
>
>No.  You do not need set the variables to 'Nothing' at the end of the method
>because this is done automatically.

Sorry, how is it done automatically? It looks to me like obj1/obj2 are
not local variables; they're either class variables or global
variables. And so a pointer to them will remain even after the
button-click handler, and so they won't be garbage-collected. So it
ssems to me that "=nothing" is correct here.

--
Lucian
Author
8 Dec 2006 11:33 PM
Herfried K. Wagner [MVP]
Show quote Hide quote
"Lucian Wischik" <lu***@wischik.com> schrieb:
>>> Sub btn_Click(....) handles btn.Click
>>> obj1 = new cls1
>>> obj2 = new cls2
>>> ...
>>> obj1 = nothing
>>> obj2 = notihng
>>
>>No.  You do not need set the variables to 'Nothing' at the end of the
>>method
>>because this is done automatically.
>
> Sorry, how is it done automatically? It looks to me like obj1/obj2 are
> not local variables; they're either class variables or global
> variables.

.... or 'Option Explicit Off' is used.  Yes, you are right that setting
non-local variables to 'Nothing' can actually make sense -- I missed that
there is no 'Dim' in the OP's code.

--
M S   Herfried K. Wagner
M V P  <URL:http://dotnet.mvps.org/>
V B   <URL:http://dotnet.mvps.org/dotnet/faqs/>
Author
9 Dec 2006 1:17 AM
Martin Milan
Lucian Wischik <lu***@wischik.com> wrote in
Show quoteHide quote
news:khrjn295m9m21qcliue3cl3frliofa8ou7@4ax.com:

> "Herfried K. Wagner [MVP]" <hirf-spam-me-here@gmx.at> wrote:
>>> Sub btn_Click(....) handles btn.Click
>>> obj1 = new cls1
>>> obj2 = new cls2
>>> ...
>>> obj1 = nothing
>>> obj2 = notihng
>>
>>No.  You do not need set the variables to 'Nothing' at the end of the
>>method because this is done automatically.
>
> Sorry, how is it done automatically? It looks to me like obj1/obj2 are
> not local variables; they're either class variables or global
> variables. And so a pointer to them will remain even after the
> button-click handler, and so they won't be garbage-collected. So it
> ssems to me that "=nothing" is correct here.
>
> --
> Lucian
>

They look pretty local to me...

Martin
Author
9 Dec 2006 1:25 AM
Martin Milan
Martin Milan <I***@m.i.do> wrote in
Show quoteHide quote
news:Xns9894D1BB3413I8spmido@194.117.143.53:

> Lucian Wischik <lu***@wischik.com> wrote in
> news:khrjn295m9m21qcliue3cl3frliofa8ou7@4ax.com:
>
>> "Herfried K. Wagner [MVP]" <hirf-spam-me-here@gmx.at> wrote:
>>>> Sub btn_Click(....) handles btn.Click
>>>> obj1 = new cls1
>>>> obj2 = new cls2
>>>> ...
>>>> obj1 = nothing
>>>> obj2 = notihng
>>>
>>>No.  You do not need set the variables to 'Nothing' at the end of the
>>>method because this is done automatically.
>>
>> Sorry, how is it done automatically? It looks to me like obj1/obj2
>> are not local variables; they're either class variables or global
>> variables. And so a pointer to them will remain even after the
>> button-click handler, and so they won't be garbage-collected. So it
>> ssems to me that "=nothing" is correct here.
>>
>> --
>> Lucian
>>
>
> They look pretty local to me...
>
> Martin
>

Argh! Ok - based on the actual code, no they don't look local. Based on
what's happening to them though, the odds are that they should be!
Author
9 Dec 2006 4:13 PM
Robinson
and that, gentlemen, is why I always underscore class scope variables with
m_ ;)

Show quoteHide quote
"Martin Milan" <I***@m.i.do> wrote in message
news:Xns9894E76CA884I8spmido@194.117.143.53...
> Martin Milan <I***@m.i.do> wrote in
> news:Xns9894D1BB3413I8spmido@194.117.143.53:
>
>> Lucian Wischik <lu***@wischik.com> wrote in
>> news:khrjn295m9m21qcliue3cl3frliofa8ou7@4ax.com:
>>
>>> "Herfried K. Wagner [MVP]" <hirf-spam-me-here@gmx.at> wrote:
>>>>> Sub btn_Click(....) handles btn.Click
>>>>> obj1 = new cls1
>>>>> obj2 = new cls2
>>>>> ...
>>>>> obj1 = nothing
>>>>> obj2 = notihng
>>>>
>>>>No.  You do not need set the variables to 'Nothing' at the end of the
>>>>method because this is done automatically.
>>>
>>> Sorry, how is it done automatically? It looks to me like obj1/obj2
>>> are not local variables; they're either class variables or global
>>> variables. And so a pointer to them will remain even after the
>>> button-click handler, and so they won't be garbage-collected. So it
>>> ssems to me that "=nothing" is correct here.
>>>
>>> --
>>> Lucian
>>>
>>
>> They look pretty local to me...
>>
>> Martin
>>
>
> Argh! Ok - based on the actual code, no they don't look local. Based on
> what's happening to them though, the odds are that they should be!
Author
9 Dec 2006 4:56 PM
Martin Milan
"Robinson" <b**@bbb.com> wrote in
news:LYKdnUNA2dgvfefYnZ2dnUVZ8tSdnZ2d@giganews.com:

> and that, gentlemen, is why I always underscore class scope variables
> with m_ ;)
>

Which is a very good practice to be in, but my employer gets all upset
about it... We have a very large application in VB6, which in turn has a
very interesting undocumented feature in that it is only able to handle
32'000 identifiers in any one project. We've hit that figure
(developmentment team of 14 people, continuous development for
customers...), and they tried hitting me for it claiming it was my "m"
habit (and hungarian notation, as was the vogue at the time) that was
responsible...

Fortunately I am now looking at a re-write in either VB.Net or C#, and
this time, the overall design of the application will be a hell of a lot
better - as we now have "a few good men" in the rank and file who are
prepared to make a point of it...

Martin
Author
9 Dec 2006 5:47 PM
Tim Patrick
I've hit the 32,000 limit before, too. But just to be clear, it is 32,000
"unique" identifiers. If you bring commonality to a lot of the local variable
names and control names between forms/files, you can possibly ease yourself
away from the limit. That was my solution before the project was upgraded
to .NET.
-----
Tim Patrick - www.timaki.com
Start-to-Finish Visual Basic 2005

Show quoteHide quote
> "Robinson" <b**@bbb.com> wrote in
> news:LYKdnUNA2dgvfefYnZ2dnUVZ8tSdnZ2d@giganews.com:
>> and that, gentlemen, is why I always underscore class scope variables
>> with m_ ;)
>>
> Which is a very good practice to be in, but my employer gets all upset
> about it... We have a very large application in VB6, which in turn has
> a very interesting undocumented feature in that it is only able to
> handle 32'000 identifiers in any one project. We've hit that figure
> (developmentment team of 14 people, continuous development for
> customers...), and they tried hitting me for it claiming it was my "m"
> habit (and hungarian notation, as was the vogue at the time) that was
> responsible...
>
> Fortunately I am now looking at a re-write in either VB.Net or C#, and
> this time, the overall design of the application will be a hell of a
> lot better - as we now have "a few good men" in the rank and file who
> are prepared to make a point of it...
>
> Martin
>
Author
9 Dec 2006 8:30 PM
Martin Milan
Tim Patrick <inva***@invalid.com.invalid> wrote in
news:e3b4697635fd8c8e98e31a34f2e@newsgroups.comcast.net:

> I've hit the 32,000 limit before, too. But just to be clear, it is
> 32,000 "unique" identifiers. If you bring commonality to a lot of the
> local variable names and control names between forms/files, you can
> possibly ease yourself away from the limit. That was my solution
> before the project was upgraded to .NET.
> -----
> Tim Patrick - www.timaki.com
> Start-to-Finish Visual Basic 2005


Thanks for that Patrick - we have already identified that it's unique
names that matter. That's my fault for not putting it in the post, but I
figured anyone who put "32'000" and "identifiers" together would know
what I'm talking about.

Are you aware of whether or not the DotNet compilers have a similar
restriction? We've tried asking Microsoft, but we didn't exactly get an
answer...

One of my colleagues has developed a program that tells us how many
unique identifiers we have in a VB project, and also one that spits them
out into a text file. I've written a C# program to read that file, and
allow queries like "I'm looking for something with both "gd", and "pick"
in it... That's allowed me to increase reuse of idenitifer names, but it
goes against the grain... I'm firmly of the belief that identifier names
should be descriptive, but more that that, accurate...

We're hoping to move to a fully dotnet product in the next couple of
years, but I've had trouble getting management to understand how serious
this probem actually is. We've bought and applied a project analysys
tool that went through the code and removed 1700 dead variables, but the
rate we're going we'll be back at 32'000 in the next couple of months...

I'm still smarting over the abandonment of VB6 to be honest (though I do
like dotnet - Inheritance etc...), and having the rug pulled out from
under me once has made me think carefully about where I want to go as a
developer. I've considered switching across to Java, but that doesn't
have a great deal of support in the office - most of our guys have only
ever known VB, so semi-colons and curly braces scare 'em...

I'm also nervous about how long VB.Net will be around, as people I speak
with all seem to be of the view that C# is going to be where the action
is. I suppose as long as they keep releasing a VB compiler that works
with the latest framework, all should be well...

Cheers for your thoughts...

Martin
Author
9 Dec 2006 10:12 PM
Tim Patrick
I don't believe that .NET has anything like the 32,000 limitation. VB6 had
other limitations, too, such as controls on a form. I believe that they have
all gone away in .NET, but I'm not familiar with the compiler internals to
say for sure.

But even if there is a similar limit in .NET, you can get around it by breaking
your program up into multiple assemblies, and then letting them work together
in the final application. In the large app I spoke of, I took about 100 of
the core generic routines and moved them into a "Common" assembly. Then I
referenced this assembly from the main application, and from several of the
helper applications that in VB6 had source code copies of those same routines.
It's really made the work much easier.

In VB6, one program that helped me a lot was VBCompressPro, from WhippleWare.
It did a pretty good analysis of the source code so that I could reduce overuse,
and it found unused code and variables, although this is a feature that Visual
Studio 2005 has built in.

I wouldn't worry about the VB/C# issue. Although I don't work for Microsoft,
I interact with some on the VB team regularly, and I have felt no reduction
in Microsoft's commitment to VB. If anything, they see an improved VB as
their key chance to bring entry-level programmers into the Microsoft fold.
And since it has all the power of C#, it's a wise choice for new developers.
Some on this forum may disagree with me, and I'm no prophet. But even in
the worst-case scenario, if Microsoft were to pull the plug on VB's .NET
variation, the conversion of your source code from VB.NET into C#.NET could
be automated with at least a 98% line-by-line success rate.

-----
Tim Patrick - www.timaki.com
Start-to-Finish Visual Basic 2005

Show quoteHide quote
> Tim Patrick <inva***@invalid.com.invalid> wrote in
> news:e3b4697635fd8c8e98e31a34f2e@newsgroups.comcast.net:
>
>> I've hit the 32,000 limit before, too. But just to be clear, it is
>> 32,000 "unique" identifiers. If you bring commonality to a lot of the
>> local variable names and control names between forms/files, you can
>> possibly ease yourself away from the limit. That was my solution
>> before the project was upgraded to .NET.
>> -----
>> Tim Patrick - www.timaki.com
>> Start-to-Finish Visual Basic 2005
> Thanks for that Patrick - we have already identified that it's unique
> names that matter. That's my fault for not putting it in the post, but
> I figured anyone who put "32'000" and "identifiers" together would
> know what I'm talking about.
>
> Are you aware of whether or not the DotNet compilers have a similar
> restriction? We've tried asking Microsoft, but we didn't exactly get
> an answer...
>
> One of my colleagues has developed a program that tells us how many
> unique identifiers we have in a VB project, and also one that spits
> them out into a text file. I've written a C# program to read that
> file, and allow queries like "I'm looking for something with both
> "gd", and "pick" in it... That's allowed me to increase reuse of
> idenitifer names, but it goes against the grain... I'm firmly of the
> belief that identifier names should be descriptive, but more that
> that, accurate...
>
> We're hoping to move to a fully dotnet product in the next couple of
> years, but I've had trouble getting management to understand how
> serious this probem actually is. We've bought and applied a project
> analysys tool that went through the code and removed 1700 dead
> variables, but the rate we're going we'll be back at 32'000 in the
> next couple of months...
>
> I'm still smarting over the abandonment of VB6 to be honest (though I
> do like dotnet - Inheritance etc...), and having the rug pulled out
> from under me once has made me think carefully about where I want to
> go as a developer. I've considered switching across to Java, but that
> doesn't have a great deal of support in the office - most of our guys
> have only ever known VB, so semi-colons and curly braces scare 'em...
>
> I'm also nervous about how long VB.Net will be around, as people I
> speak with all seem to be of the view that C# is going to be where the
> action is. I suppose as long as they keep releasing a VB compiler that
> works with the latest framework, all should be well...
>
> Cheers for your thoughts...
>
> Martin
>
Author
9 Dec 2006 11:41 PM
Martin Milan
Tim Patrick <inva***@invalid.com.invalid> wrote in
news:e3b46976361d8c8e9b33b05f57e@newsgroups.comcast.net:

> I don't believe that .NET has anything like the 32,000 limitation. VB6
> had other limitations, too, such as controls on a form. I believe that
> they have all gone away in .NET, but I'm not familiar with the
> compiler internals to say for sure.

Thanks again Tim...

We've hit the controls on a form issue before in vb6 - 255 of those, but
you can get around it by using control arrays.

Thanks for the reassurance on the identifiers in dotnet question - I'll
sleep a little easier.

> But even if there is a similar limit in .NET, you can get around it by
> breaking your program up into multiple assemblies, and then letting
> them work together in the final application. In the large app I spoke
> of, I took about 100 of the core generic routines and moved them into
> a "Common" assembly. Then I referenced this assembly from the main
> application, and from several of the helper applications that in VB6
> had source code copies of those same routines. It's really made the
> work much easier.

Yep - been there, done that... We have over 45 activex dlls hanging off
the main application. I've moved everything from the main application
that could be moved (by checking the dependencies) into a "main" dll,
and then moved looked for anything else that can be moved - no real joy
there though... We're talking about a big product (obviously...) in use
on every continent...

> In VB6, one program that helped me a lot was VBCompressPro, from
> WhippleWare. It did a pretty good analysis of the source code so that
> I could reduce overuse, and it found unused code and variables,
> although this is a feature that Visual Studio 2005 has built in.

I can't tell you which product we used (I wasn't assigned that job...),
but I know it came from Finland and cost about 800 GBP...


> I wouldn't worry about the VB/C# issue. Although I don't work for
> Microsoft, I interact with some on the VB team regularly, and I have
> felt no reduction in Microsoft's commitment to VB. If anything, they
> see an improved VB as their key chance to bring entry-level
> programmers into the Microsoft fold. And since it has all the power of
> C#, it's a wise choice for new developers. Some on this forum may
> disagree with me, and I'm no prophet. But even in the worst-case
> scenario, if Microsoft were to pull the plug on VB's .NET variation,
> the conversion of your source code from VB.NET into C#.NET could be
> automated with at least a 98% line-by-line success rate.

Yeah, I looked at the suitability of VB.NET for any possible conversion
into C#. I came to the conclusion most of it would be ok, and from
memory I think my only serious concern was than c# didn't have the same
sort of support for optional variables.

Between the two languages I guess it's swings and roundabouts - vb
doesn't support operator overloading for example... As I'm fairly
confident using either, I plan to write mainly in VB (ease of use for my
colleagues using my code), and use C# for anything that needs it. Which
I don't think will be much...

Cheers for your time Tim...

Martin.
Author
10 Dec 2006 5:34 AM
RobinS
VB.NET doesn't support Operator Overloading? Are you sure?
That's the title of the chapter I just started in Mr. Patrick's
book. And I could have sworn I saw a bunch of stuff about it
in Francesca Balena's "VB2005: The Language". (Both are
great books, by the way.) What version of .Net are you talking
about? Am I talking about the same thing you are? Overloading
+, -, *, /, etc.?

Robin S.
------------------------
Show quoteHide quote
"Martin Milan" <I***@m.i.do> wrote in message
news:Xns9894F0F29143AI8spmido@194.117.143.53...
> Tim Patrick <inva***@invalid.com.invalid> wrote in
> news:e3b46976361d8c8e9b33b05f57e@newsgroups.comcast.net:
>
>> I don't believe that .NET has anything like the 32,000 limitation.
>> VB6
>> had other limitations, too, such as controls on a form. I believe
>> that
>> they have all gone away in .NET, but I'm not familiar with the
>> compiler internals to say for sure.
>
> Thanks again Tim...
>
> We've hit the controls on a form issue before in vb6 - 255 of those,
> but
> you can get around it by using control arrays.
>
> Thanks for the reassurance on the identifiers in dotnet question -
> I'll
> sleep a little easier.
>
>> But even if there is a similar limit in .NET, you can get around it
>> by
>> breaking your program up into multiple assemblies, and then letting
>> them work together in the final application. In the large app I spoke
>> of, I took about 100 of the core generic routines and moved them into
>> a "Common" assembly. Then I referenced this assembly from the main
>> application, and from several of the helper applications that in VB6
>> had source code copies of those same routines. It's really made the
>> work much easier.
>
> Yep - been there, done that... We have over 45 activex dlls hanging
> off
> the main application. I've moved everything from the main application
> that could be moved (by checking the dependencies) into a "main" dll,
> and then moved looked for anything else that can be moved - no real
> joy
> there though... We're talking about a big product (obviously...) in
> use
> on every continent...
>
>> In VB6, one program that helped me a lot was VBCompressPro, from
>> WhippleWare. It did a pretty good analysis of the source code so that
>> I could reduce overuse, and it found unused code and variables,
>> although this is a feature that Visual Studio 2005 has built in.
>
> I can't tell you which product we used (I wasn't assigned that
> job...),
> but I know it came from Finland and cost about 800 GBP...
>
>
>> I wouldn't worry about the VB/C# issue. Although I don't work for
>> Microsoft, I interact with some on the VB team regularly, and I have
>> felt no reduction in Microsoft's commitment to VB. If anything, they
>> see an improved VB as their key chance to bring entry-level
>> programmers into the Microsoft fold. And since it has all the power
>> of
>> C#, it's a wise choice for new developers. Some on this forum may
>> disagree with me, and I'm no prophet. But even in the worst-case
>> scenario, if Microsoft were to pull the plug on VB's .NET variation,
>> the conversion of your source code from VB.NET into C#.NET could be
>> automated with at least a 98% line-by-line success rate.
>
> Yeah, I looked at the suitability of VB.NET for any possible
> conversion
> into C#. I came to the conclusion most of it would be ok, and from
> memory I think my only serious concern was than c# didn't have the
> same
> sort of support for optional variables.
>
> Between the two languages I guess it's swings and roundabouts - vb
> doesn't support operator overloading for example... As I'm fairly
> confident using either, I plan to write mainly in VB (ease of use for
> my
> colleagues using my code), and use C# for anything that needs it.
> Which
> I don't think will be much...
>
> Cheers for your time Tim...
>
> Martin.
>
Author
10 Dec 2006 7:32 AM
Tim Patrick
Operator overloading was introduced into Visual Basic with the 2005 release.
It also acquired the "generics" technology with that release. Since your
product is used worldwide, you'll like the localization tools that are built
into Visual Studio, plus an external localization editor that translators
can use without having access to the source code.

-----
Tim Patrick - www.timaki.com
Start-to-Finish Visual Basic 2005

Show quoteHide quote
> Between the two languages I guess it's swings and roundabouts - vb
> doesn't support operator overloading for example... As I'm fairly
> confident using either, I plan to write mainly in VB (ease of use for
> my colleagues using my code), and use C# for anything that needs it.
> Which I don't think will be much...
>
> Martin.
>
Author
10 Dec 2006 10:56 AM
Martin Milan
Cheers again Tim...

I've just replied to the other poster on this.

I'm bally annoyed! I suspect your book is a hell of a lot cheaper than
the course I've been on, and I'm liking the sound of it more and more as
we go.  Can you give be the ISBN code please?

Martin.


Show quoteHide quote
> Operator overloading was introduced into Visual Basic with the 2005
> release. It also acquired the "generics" technology with that release.
> Since your product is used worldwide, you'll like the localization
> tools that are built into Visual Studio, plus an external localization
> editor that translators can use without having access to the source
> code.
>
> -----
> Tim Patrick - www.timaki.com
> Start-to-Finish Visual Basic 2005
Author
10 Dec 2006 1:45 PM
Tim Patrick
The ISBN is 0-321-39800-9, or you can find it at www.timaki.com. Thank you
for your interest.

-----
Tim Patrick - www.timaki.com
Start-to-Finish Visual Basic 2005

Show quoteHide quote
> Cheers again Tim...
>
> I've just replied to the other poster on this.
>
> I'm bally annoyed! I suspect your book is a hell of a lot cheaper than
> the course I've been on, and I'm liking the sound of it more and more
> as we go.  Can you give be the ISBN code please?
>
> Martin.
>
>> Operator overloading was introduced into Visual Basic with the 2005
>> release. It also acquired the "generics" technology with that
>> release. Since your product is used worldwide, you'll like the
>> localization tools that are built into Visual Studio, plus an
>> external localization editor that translators can use without having
>> access to the source code.
>>
>> -----
>> Tim Patrick - www.timaki.com
>> Start-to-Finish Visual Basic 2005
Author
10 Dec 2006 3:21 PM
Martin Milan
Tim Patrick <inva***@invalid.com.invalid> wrote in
news:e3b4697636658c8ea357b9f2bf0@newsgroups.comcast.net:

> The ISBN is 0-321-39800-9, or you can find it at www.timaki.com. Thank
> you for your interest.
>
> -----
> Tim Patrick - www.timaki.com
> Start-to-Finish Visual Basic 2005

Cheers again...

I've just ordered it through Amazon.

Martin.
Author
11 Dec 2006 3:09 AM
Tim Patrick
Thank you very much. Contact me through my web site if you have any questions
about the book once you receive it.

-----
Tim Patrick - www.timaki.com
Start-to-Finish Visual Basic 2005

Show quoteHide quote
> Tim Patrick <inva***@invalid.com.invalid> wrote in
> news:e3b4697636658c8ea357b9f2bf0@newsgroups.comcast.net:
>
>> The ISBN is 0-321-39800-9, or you can find it at www.timaki.com.
>> Thank you for your interest.
>>
>> -----
>> Tim Patrick - www.timaki.com
>> Start-to-Finish Visual Basic 2005
> Cheers again...
>
> I've just ordered it through Amazon.
>
> Martin.
>
Author
11 Dec 2006 11:02 PM
Martin Milan
Tim Patrick <inva***@invalid.com.invalid> wrote in
Show quoteHide quote
news:e3b4697636bf8c8eaa5d142d078@newsgroups.comcast.net:

> Thank you very much. Contact me through my web site if you have any
> questions about the book once you receive it.
>
> -----
> Tim Patrick - www.timaki.com
> Start-to-Finish Visual Basic 2005
>
>> Tim Patrick <inva***@invalid.com.invalid> wrote in
>> news:e3b4697636658c8ea357b9f2bf0@newsgroups.comcast.net:
>>
>>> The ISBN is 0-321-39800-9, or you can find it at www.timaki.com.
>>> Thank you for your interest.
>>>
>>> -----
>>> Tim Patrick - www.timaki.com
>>> Start-to-Finish Visual Basic 2005
>> Cheers again...
>>
>> I've just ordered it through Amazon.
>>
>> Martin.
>>
>
>
>

Thanks...

Martin.
Author
9 Dec 2006 8:09 AM
Michel Posseth [MCP]
> Is this the correct way to release destroy an object for garbage
> collection?
> (VB2005).

if these variabels are declared in object scope ( outside the method with
,Private , Friend , Public, ......)
yes it is

>Then I set all 4 classes equal to nothing to release them
> from memory/destroy them.

Well when this happens ?? who knows...  that is the mystery of the GC  don`t
expect the memory usage to drop suddenly cause it wil not

regards

Michel





Show quoteHide quote
"Rich" <R***@discussions.microsoft.com> schreef in bericht
news:9DD68F82-5857-4A11-B0BD-13AAE6FEF207@microsoft.com...
> Greetings,
>
> In a button on a form I instantiate 4 class objects.  Then, depending on
> some other selections (radio buttons) on the form, I call a procedure from
> one of the classes. Then I set all 4 classes equal to nothing to release
> them
> from memory/destroy them.
>
> Sub btn_Click(....) handles btn.Click
> obj1 = new cls1
> obj2 = new cls2
> ...
> obj1 = nothing
> obj2 = notihng
> ...
> End Sub
>
> Is this the correct way to release destroy an object for garbage
> collection?
> (VB2005).
>
> Thanks,
> Rich
Author
12 Dec 2006 4:15 PM
Rich
The object vars are global.  That is why I want to set them to nothing when I
am through with them.   I use them throughout my app in various
processes/procedures.  So rather than declaring them all over the place, I
just declare them globally but use them locally.  And yes - they are class
objects - custom objects.

Thank you all for your replies.

Show quoteHide quote
"Rich" wrote:

> Greetings,
>
> In a button on a form I instantiate 4 class objects.  Then, depending on
> some other selections (radio buttons) on the form, I call a procedure from
> one of the classes. Then I set all 4 classes equal to nothing to release them
> from memory/destroy them.
>
> Sub btn_Click(....) handles btn.Click
> obj1 = new cls1
> obj2 = new cls2
> ...
> obj1 = nothing
> obj2 = notihng
> ...
> End Sub
>
> Is this the correct way to release destroy an object for garbage collection?
> (VB2005).
>
> Thanks,
> Rich