I don't see what the problem is. I mean, if the class encapsulates your
state and logic accurately, then create them and forget about them when you
are done. That's the point of the GC. If you aren't doing anything that
requires special consideration (IDisposable, COM interop, etc, etc), then
let the GC do what it does best.
Now, if the state that you are constructing, in this case, the mapping
between the keys and urls is static (to some degree) or doesn't need to be
reconstructed every time, then you might want to consider a singleton,
assuming that the lifetime of the application domain is the same as the
lifetime of the key/url lookup table.
--
- Nicholas Paldino [.NET/C# MVP]
-
mv*@spam.guard.caspershouse.com
"DBC User" <db*****@gmail.comwrote in message
news:11**********************@v3g2000hsg.googlegro ups.com...
>I have a class which uses dictionary to look up a key to find a url.
When found it will launch the url in new IE.
Now my question is, I will be doing a new on this class when ever a
particular menu item is pressed. On the end of the method this class
is send to GC to mark for GC. Will this can cause any memory problem
or performance problem?
I am thinking of converting to singleton class but before I do I
thought you guys expert advice.
Thanks.