finalizer Questions

6

Solved

This is mostly out of curiosity. I was wandering if anyone has encountered any good usage for Object.finalize() except for debugging/logging/profiling purposes ? If you haven't encountered ...
Marcellemarcellina asked 18/11, 2010 at 13:13

2

Solved

I have a C++ unmanaged class NativeDog that needs to be used from C#, so I've create a wrapper class ManagedDog. // unmanaged C++ class class NativeDog { NativeDog(...); // constructor ~NativeDo...
Abulia asked 6/12, 2010 at 13:20

6

Solved

I've got a class named BackgroundWorker that has a thread constantly running. To turn this thread off, an instance variable named stop to needs to be true. To make sure the thread is freed when t...
Foreandaft asked 29/9, 2008 at 22:28

4

Solved

I know it's by design that you can't control what happens when an object is destroyed. I am also aware of defining some class method as a finalizer. However is the ruby idiom for C++'s RAII (Resou...
Old asked 18/10, 2008 at 5:40

2

Solved

When I read a few articles about memory management in C#, I was confused by Finalizer methods. There are so many complicated rules which related with them. For instance, nobody knows when the fin...
Anglofrench asked 3/11, 2010 at 15:9

1

Solved

So here is the story so far, I have this worker thingy which uses an AppDomain to perform some task. The domain is expensive to setup and teardown. So I create a cache per-thread of WeakReference o...
Robbert asked 31/10, 2010 at 19:34

6

Solved

Based on the documentation (MSDN: link), it is clear that one should use the IDisposable pattern when implementing a finalizer. But do you need to implement a finalizer if you implement IDisposabl...
Jook asked 7/10, 2010 at 14:40

5

Solved

In Java, finalize is called on an object (that overrides it) when it's about to be garbage collectioned, so when it's unreachable. But what if the finalizer makes the object reachable again, what h...
Phillips asked 27/9, 2010 at 21:37

1

Solved

Disclaimer: I know IDisposable should be implemented when dealing with unmanaged resources. The rest of the code should be deterministic and do using (...) { } (equivalent of try {} finally { Dispo...
Necrosis asked 3/9, 2010 at 16:7

2

Solved

Are finalizers guaranteed to be executed in .NET at some point (spare power outages and the like)? I know how GC works and that it is nondeterministic when exactly they'll run. (The search did not...
Coper asked 11/8, 2010 at 12:26

1

Solved

I have been reading these slides about Java finalizers. In it, the author describes a scenario (on slide 33) whereby CleanResource.finalize() could be run by the finalizer thread while CleanResourc...
Tuantuareg asked 29/7, 2010 at 13:39

4

Solved

I learned that calling an Object's wait() method will release the object monitor, if present. But I have some questions regarding calling notify() on this object by another thread: (when) will t...
Aney asked 6/7, 2010 at 21:57

6

Solved

Effective Java says : There is a severe performance penalty for using finalizers. Why is it slower to destroy an object using the finalizers?

2

Solved

I have been pondering why it is recommended that we should not release managed resources inside finalize. If you see the code example at http://msdn.microsoft.com/en-us/library/system.gc.suppressf...
Chaechaeronea asked 22/4, 2010 at 6:26

1

Solved

Is it possible to add a Finalizer to a CodeDom generated class (other than using CodeSnippetTypeMember)? I couldn't find any information about it on MSDN.
Sheerlegs asked 8/2, 2010 at 12:3

3

Solved

I'm writing a Excel class using Microsoft.Interropt.Excel DLL. I finish all function but I have an error in my Destructor. I Want to save all changes to my file and I want to release all source. I ...
Comply asked 18/1, 2010 at 12:28

1

Solved

Here's some sample code: using System; namespace UnloadFromFinalizer { class Program { static void Main(string[] args) { Program p = new Program(); } AppDomain domain; Program() { this....
Bonnybonnyclabber asked 11/12, 2009 at 23:9

4

Solved

Please Note: This question is about the difference in terminology between the words "destructor" and "finalizer" and their correct usage. I have merely provided examples of their use in C# and C++/...
Grimonia asked 9/12, 2009 at 9:40

4

Solved

I am using a search library which advises keeping search handle object open for this can benefit query cache. Over the time I have observed that the cache tends to get bloated (few hundred megs and...
Glaucoma asked 28/10, 2009 at 17:37

3

Solved

I noticed that System.Threading.Thread implements a finalizer but not IDisposable. The recommended practice is to always implement IDisposable when a finalizer is implemented. Jeffrey Richter wrote...
Selmner asked 11/11, 2009 at 17:45

2

Solved

I have a managed object that calls a COM server to allocate some memory. The managed object must call the COM server again to free that memory before the managed object goes away to avoid a memory ...
Tracheid asked 15/10, 2009 at 17:45

3

Solved

Is there any way to "automatically" run finalization / destructor code as soon as a variable loses scope in a .Net language? It appears to me that since the garbage collector runs at an indetermina...
Cannonball asked 14/9, 2009 at 18:0

3

Solved

I have a WindowsForms app that appears to leak memory, so I used Redgate's ANTS Memory Profiler to look at the objects I suspect and find that they are only held by objects already on the Finalizer...
Aubarta asked 12/8, 2009 at 20:25

5

Solved

What happens if you save a reference to the current object during the finalize call? For example: class foo { ... public void finalize() { bar.REFERENCE = this; } } Is the object garbage-col...
Aldin asked 16/6, 2009 at 16:25

5

Solved

I have been programming in .NET for four years (mostly C#) and I use IDiposable extensively, but I am yet to find a need for a finaliser. What are finalisers for?
Sedation asked 20/4, 2009 at 14:27

© 2022 - 2024 — McMap. All rights reserved.