I am working on an application whose purpose is to compute reports has fast as possible. My application uses a big amount of memory; more than 100 Go. Since our last release, I notice a big performance slowdown. My investigation shows that, during th
In my application, I have a Dictionary<int, WeakReference<Foo>> to cache Foos read from a file, where the key is the index in the file. Since the Foos are mutable, a cache entry must remain alive as long as any reference to the Foo at that ind
Is it right that in C# Destructor (Finalizer) you can not access managed members of your class? If it is true, why is it? What other C# finalizer restrictions you know? Example: class MyClass { private FileStream _fs; private IntPtr _handle; public v
Does Java have an equivalent of .Net's GC.SuppressFinalize? In .Net, SuppressFinalize is used in the dispose pattern to avoid the relatively high performance cost of finalization as long as the object is explicitly disposed. Similar costs apply to Ja
My application makes use of a third-party library (the JTDS driver) that has some objects that override the finalize() method. I think they obey all the rules about when not to use finalize() - it doesn't depend on them running in a timely manner or
The main question is in the topic but let me show my vision of finalization proccess in Java so that I can ask you a little more. Well the gc starts garbage collection by marking all live objects. When all reachable objects are marked as "live".
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 advantage of using shutdown hook over finalize method. A
I'm investigating GC and memory use in our application, and have noticed we seem to have thousands of finalization survivors. Unfortunately, the number alone doesn't really tell me whether we have a problem. We are seeing general performance issues h
what will the Finalizer thread do if there is a infinite loop or deadlock in the Java finalize method.The spec writes: Before the storage for an object is reclaimed by the garbage collector, the Java Virtual Machine will invoke the finalizer of that
I have an ImageWrapper class that saves images to temporary files in disk in order to free heap memory, and allows reloading them when needed. class ImageWrapper { File tempFile; public ImageWrapper(BufferedImage img) { // save image to tempFile and
I wanted a way to break the IDisposable chain where some nested class that you suddenly depend on now implements IDisposable and you don't want that interface to ripple up the layers of your composite. Basically, I have weak subscriptions to IObserva
To learn C# native interop, I've been working on an OpenGL wrapper. The OpenGL API itself is a state machine which is bound to a specific thread. When an object containing native resources is garbage collected, the finalizer is running in the GC thre
I'am working on an application that has problems with its memory consumption. If a user clicks long enough in the application it ends in an OutOfMemoryException. I profiled the application with 'ANTS Memory Profiler' quite a long time and in my opini
In the course of a discussion in chat, I wrote this console application. Code: using System; class Program { static void Main(string[] args) { CreateClass(); Console.Write("Collecting... "); GC.Collect(); Console.WriteLine("Done"); } s
I have idea about Dispose and Finalize method in .Net as following. Please correct me if I am wrong. Dispose : Implement IDisposable inferface and remove unused/unmanaged code in Dispose method. Developer needs to call it manually if they want immedi
I have written a custom trace listener extending TextWriterTraceListener. Now, how do I call the Dispose() on the listener? I add it through the app.config of my project. Tried adding the call Dispose(false) in the finalizer, but it not being called.
In answering another question on SO, and the subsequent comment discussion, I ran into a wall on a point that I'm not clear on. Correct me on any point where I'm astray... When the Garbage Collector collects an object, it calls that object's finalize
I have a class with a finalizer. But since I'm always calling Dispose() and Dispose() is calling GC.SupressFinalize(this), I think my object never actually makes it into the finalization queue. The finalizer is just in there as a backstop in case ano
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 I have two questions about this implementation, that y
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 finalizers will be called, they called even if code in cto
Suppose I have a message pump class in C++0x like the following (note, SynchronizedQueue is a queue of function<void()> and when you call receive() on the queue and it is empty, it blocks the calling thread until there is an item to return): class M
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 the waiting thread wake up, if another (a 3rd) thread own
I have the following class which is a decorator for an IDisposable object (I have omitted the stuff it adds) which itself implements IDisposable using a common pattern: public class DisposableDecorator : IDisposable { private readonly IDisposable _in
Class ComponentsContainer ' a component contains other components' Inherits System.ComponentModel.Component Private foo as New Component Private bar as New Component Protected Override Sub Finalize() foo.Dispose() ' HERE ? ' bar.Dispose() MyBase.Fina
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 leak. This object implements IDisposable to help ensu
I am relatively new to WPF, and some things with it are quite foreign to me. For one, unlike Windows Forms, the WPF control hierarchy does not support IDisposable. In Windows Forms, if a user control used any managed resources, it was very easy to cl
I have a DataGridView being regularly populated via data-bound objects, and the number of rows can potentially become large, say many thousands during a 'logging cycle'. When a new 'logging cycle' begins, the grid is cleared because the underlying da
I have a .NET C# / C++ app which uses a call to exit(0) (from <stdlib.h>) in a thread in order to terminate. The strange part is, under some circumstances, the finalizers of the managed objects are called right after the call to exit, and in other c
Is it legal to write the following in .net ? public class A { public int i = 0; ~A() { Aref = this; } } public static A Aref; static void Main(string[] args) { Aref = new A(); int gen = GC.GetGeneration(Aref); Aref = null; GC.Collect(gen, GCCollectio
I keep a cache of transactions to flush (to persistent storage) on the event of a watermark or object finalization. Since __del__ is no longer guaranteed to be called on every object, is the appropriate approach to hook a similar function (or __del__