473,385 Members | 1,796 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

memory allocation and GC

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.

Nov 14 '07 #1
2 1487
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.

Nov 14 '07 #2
On Nov 14, 11:41 am, "Nicholas Paldino [.NET/C# MVP]"
<m...@spam.guard.caspershouse.comwrote:
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]
- m...@spam.guard.caspershouse.com

"DBC User" <dbcu...@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.- Hide quoted text -

- Show quoted text -
Thanks it answers my question.

Nov 14 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: chris | last post by:
Hi all, I need to know, what is the difference between dynamic memory allocation, and stack allocation ? 1. If I have a class named DestinationAddress, when should I use dynamic memory...
4
by: PaulR | last post by:
Hi, We have a Server running SLES 8 and 3GB memory, with 1 DB2 instance and 2 active Databases. General info... DB2level = "DB2 v8.1.0.72", "s040914", "MI00086", and FixPak "7" uname -a =...
74
by: ballpointpenthief | last post by:
If I have malloc()'ed a pointer and want to read from it as if it were an array, I need to know that I won't be reading past the last index. If this is a pointer to a pointer, a common technique...
62
by: ivan.leben | last post by:
How can I really delete a preloaded image from memory/disk cache? Let's say I preload an image by creating an Image object and setting its src attribute to desired URL: var img = new Image();...
66
by: Johan Tibell | last post by:
I've written a piece of code that uses sockets a lot (I know that sockets aren't portable C, this is not a question about sockets per se). Much of my code ended up looking like this: if...
24
by: Ken | last post by:
In C programming, I want to know in what situations we should use static memory allocation instead of dynamic memory allocation. My understanding is that static memory allocation like using array...
1
by: Peterwkc | last post by:
Hello all expert, i have two program which make me desperate bu after i have noticed the forum, my future is become brightness back. By the way, my problem is like this i the first program was...
34
by: jacob navia | last post by:
Suppose that you have a module that always allocates memory without ever releasing it because the guy that wrote it was lazy, as lazy as me. Now, you want to reuse it in a loop. What do you do?...
14
by: vivek | last post by:
i have some doubts on dynamic memory allocation and stacks and heaps where is the dynamic memory allocation used? in function calls there are some counters like "i" in the below function. Is...
66
by: karthikbalaguru | last post by:
Hi, Will 'free' return the memory Immediately to the OS ? Thx in advans, Karthik Balaguru
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.