memory allocation and GC

D

DBC User

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.
 
N

Nicholas Paldino [.NET/C# MVP]

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.
 
D

DBC User

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]
- (e-mail address removed)




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.- Hide quoted text -

- Show quoted text -

Thanks it answers my question.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top