|
-
November 6th, 2008, 02:44 PM
#16
Re: Memory leak example?
May I refer you to this post.
Also, I have my PMs enabled now, so what is it you wanted to say?
Addendum: Perhaps the mods can add the words "Memory Leak" to the bad words filter for the C# forum.
Last edited by DeepT; November 6th, 2008 at 02:57 PM.
-
November 7th, 2008, 06:52 AM
#17
Re: Memory leak example?
 Originally Posted by TheCPUWizard
How would that generate a leak????
Here is my and wikipedia definition on a memory leak:
 Originally Posted by Wikipedia
In computer science, a memory leak is a particular type of unintentional memory consumption by a computer program where the program fails to release memory when no longer needed. This condition is normally the result of a bug in a program that prevents it from freeing up memory that it no longer needs.
If you unintentionally use up more and more memory... you got a leak.
- petter
-
November 7th, 2008, 07:05 AM
#18
Re: Memory leak example?
Is the philosophy of .NET not to avoid mem leaks by using the Garbage Collector?
I thought that .NET takes care about used memory and releases it, if
required.
So for .NET developers no memory leaks can occur.
If I'm wrong, tell me.
-
November 7th, 2008, 09:16 AM
#19
Re: Memory leak example?
 Originally Posted by wildfrog
Here is my and wikipedia definition on a memory leak:
In computer science, a memory leak is a particular type of unintentional memory consumption by a computer program where the program fails to release memory when no longer needed. This condition is normally the result of a bug in a program that prevents it from freeing up memory that it no longer needs..
- petter
1) NEVER trust WikiPedia...It is often a good starting point, but a many (most?) items contain at least one (typically minor) in-accuracy...
In the case of the "dangling event", it will does not meet the criteria as it does not satisify the "no longer needs" portion.
Code:
1) WE sign a contract that you will notify me of certain facts when something happens.
2) Time passes, and I no longer care about this, but do NOT inform you and have the contract terminated (along with any side effects of the termination)
3) YOU still have the responsibility of notifying me.
4) I still have the responsibility of accepting that notification.
If I terminate my means of accdepting the notification, I would be in violation of the contract. I must (legally) keep the means of communication open.
Now if we translate this into the "event" issue, we see the same exact condition. The object is question (the one with no references OTHER THAN the contractual reference in the delegate) is OBLIGATED to remain in existance. It is STILL REQUIRED.
To go to a more general case, consider that EVERY object "exists" for a period of time in .NET after it is no longer needed (from the removal of the last reference to the object, until the GC runs for the generation which owns the object. From a programmers perspective, the object is "no longer needed". But this is not considered a leak....
TheCPUWizard is a registered trademark, all rights reserved. (If this post was helpful, please RATE it!)
2008, 2009,2010
In theory, there is no difference between theory and practice; in practice there is.
* Join the fight, refuse to respond to posts that contain code outside of [code] ... [/code] tags. See here for instructions 
* How NOT to post a question here
* Of course you read this carefully before you posted
* Need homework help? Read this first
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|