Initially I was not destroying exactly for that reason. But when the
Asp.Net
process was taking 50% of the memory with two users using the applictaion,
I
thought I should explicitly destroy these objects.
An assumption on your part. First, 50% is not an amount, but a ratio, so I
have no idea how much memory you're talking about. Second, assuming that the
app *is* consuming an excessive amount of memory (and that is quite the
assumption; .Net manages memory quite well, but will not discard it
immediately), the real problem would be to determine exactly what is causing
the excessive use of memory. Let's say that your car is using too much gas.
Would you assume that changing the spark plugs would fix the problem, or
would you identify all of the possible causes of excessive gas use, and
check each related component to find out which one was misbehaving and why,
and then fix that component? In other words, some diagnostics are necessary
before any attempt to fix the issue is made.
Are you implying that the changes I have made will have no impact on the
memory problem?
If I implied that, I would be making an assumption myself. First, I have no
idea what changes you have made. You have talked about "destroying objects,"
but as I told you, that is not something you can do. They are managed, and
the option to destroy them is not one available to the developer. So, since
you say that "I tried destroying these objects in the page_unload event,"
and it is not possible to destroy .Net objects, I can't presume to know what
you did to your code as an attempt to destroy them.
I could presuppose that you assigned a null (Nothing) value to them, but if
so, that would be of no effect. For one thing, a variable or field is simply
a container for an object. It is not an object itself. When you set the
value of a variable, you are only saying to the computer, "when I reference
this name, I am referencing that object." When you set the value of a
variable to Nothing, you are saying to the computer, "when I reference this
name, I am not referencing anything."
So, in order to help you, you will need to fill in the blanks where I have
indicated. How much memory are we talking about? What sort of objects are
you using, and how are you using them?
--
HTH,
Kevin Spencer
Microsoft MVP
..Net Developer
Complex things are made up of
Lots of simple things.