finalizer Questions
2
I know that Finalize method is used by garbage collector to let object free up unmanaged resources. And from what I know, Object.Finalize is never called directly by GC (object is added to f-reacha...
Ravid asked 11/10, 2017 at 14:50
9
Solved
I'm not quite understanding why there are finalizers in languages such as java and c#. AFAIK, they:
are not guaranteed to run (in java)
if they do run, they may run an arbitrary amount of time af...
Melpomene asked 5/12, 2009 at 1:24
2
Javadoc 8 for PhantomReference
states:
Phantom references are most often used for scheduling pre-mortem cleanup actions in a more flexible way than is possible with the Java finalization mechan...
Gog asked 9/4, 2017 at 20:54
5
Solved
I have few Question for which I am not able to get a proper answer .
1) Why should we call SuppressFinalize in the Dispose function when we don't have a destructor .
2) Dispose and finalize are u...
Alforja asked 9/4, 2010 at 6:14
2
I have read many articles how finalizer works. Here is my understanding: If a class have finalize method implemented Jvm would create an instance of Finalizer as a watch dog on that object.
When ...
2
Solved
I have a class which starts a Task and want to ensure that the Task stops when the object is garbage collected.
I have implemented the IDisposable pattern to ensure that if the object is disposed...
Annoyance asked 6/4, 2016 at 9:48
5
Solved
Ok, it's known that GC implicitly calls Finalize methods on objects when it identifies that object as garbage. But what happens if I do a GC.Collect()? Are the finalizers still executed? Someone as...
Eckert asked 19/12, 2012 at 14:46
1
Solved
According to Essential C# 6.0 you should:
AVOID calling Dispose() on owned objects that have a finalizer.
Instead, rely on the finalization queue to clean up the instance.
Could someone plea...
1
Solved
I understand that in .NET, finalizers are run even if an object is partially constructed (e.g. if an exception is thrown out of its constructor), but what about when the constructor was never run a...
2
Solved
I just fail to understand why must one use Runtime.addShutdownHook. If you want to do some cleanup when the jvm exits, why not just overload the finalize method of the daemon class. What is the adv...
Moniz asked 29/12, 2013 at 19:29
3
Solved
I have a question about how to use Dispose() and destructors. Reading some articles and the MSDN documentation, this seems to be the recommended way of implementing Dispose() and destructors.
But...
Dowson asked 6/1, 2011 at 13:12
15
Solved
I was having a discussion with a colleague recently about the value of Dispose and types that implement IDisposable.
I think there is value in implementing IDisposable for types that should clean u...
Fauman asked 25/4, 2012 at 13:12
1
I have an application with some objects (of type BaseTexture) on which an explicit destroy function should be called when they aren't of any more use. Otherwise they might leak some memory. This sh...
Concoction asked 6/7, 2015 at 15:35
3
Solved
In our framework, there is some key objects which have file handles or WCF client connections. Those objects are IDiposable and we have validation code (with exceptions being thrown) to ensure that...
2
IDisposable pattern is expensive to implement. I've counted 17 lines of code before even starting to actually dispose resources.
Eric Lippert recently wrote a blog post bringing up an interesting ...
Cuthburt asked 3/9, 2015 at 10:48
2
Solved
In the book Headfirst C#, I get the point of view that "it's not a good idea to serialize an object in its finalizer, since serialization requires the whole object tree to be in the heap, but you m...
4
Solved
Destructors are weird. I was attempting to eliminate the need of using the disposable pattern by using 'smart' reference management, ensuring that the garbage collector could collect objects at the...
Oid asked 30/3, 2012 at 11:1
1
I have noticed inconsistent behavior from the GC when compiling console applications under both 32-bit and 64-bit in .Net 4.0 using VS 2013.
Consider the following code:
class Test
{
public stat...
Tisbee asked 15/5, 2015 at 8:5
1
I've been studying memory leaks and using memory analyser tool to check them. So, as a practice, I have following code which leaks an activity as the anonymous inner class holds a reference to the ...
Barefoot asked 15/4, 2015 at 15:48
3
Solved
The function runtime.SetFinalizer(x, f interface{}) sets the finalizer associated with x to f.
What kind of objects are finalized by default?
What are some of the unintended pitfalls caused by ha...
Jacquetta asked 21/12, 2011 at 19:49
1
Solved
The Finalizer is never called after leaving the activity. Does that mean the activity is still alive even though I moved on to the next activity.
namespace XamarinTest {
[Activity(Label = "Xamarin...
4
My understanding about this class is that you should use it when you want to be sure that the Finalizer (destructor) of the class is called, but from a couple of tests I did, it doesn't seem to be ...
1
Solved
I'm seeing an issue with some code I maintain. The code below has a private static SHA1 member (which is an IDisposable but since it's static, it should never get finalized). However, under stress ...
Bowrah asked 27/10, 2014 at 16:48
2
Solved
EDIT
See edit note at the bottom of the question for additional detail.
Original question
I have a CacheWrapper class which creates and holds onto an instance of the .NET MemoryCache class intern...
System asked 8/10, 2014 at 19:5
13
Solved
C# 2008
I have been working on this for a while now, and I am still confused about the use of finalize and dispose methods in code. My questions are below:
I know that we only need a finalizer w...
Oday asked 22/5, 2009 at 16:44
© 2022 - 2024 — McMap. All rights reserved.