Finalization is intended for questions regarding programmatically releasing memory in conjuction with garbage collection, external resources and weak references.
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 up as soon as possible, even if there are no…
In my experience as a C++/Java/Android developer, I have come to learn that finalizers are almost always a bad idea, the only exception being the management of a "native peer" object needed by the java one to call C/C++ code through JNI.
I am aware…
(This question is different from Why would you ever implement finalize()? This question is about deprecation from the Java platform, and the other question is about whether one should use this mechanism in applications.)
Why is the finalize() method…
In Java, overriding the finalize method gets a bad rap, although I don't understand why. Classes like FileInputStream use it to ensure close gets called, in both Java 8 and Java 10. Nevertheless, Java 9 introduced java.lang.ref.Cleaner which uses…
Apparently, Constrained Execution Region guarantees do not apply to iterators (probably because of how they are implemented and all), but is this a bug or by design? [See the example below.]
i.e. What are the rules on CERs being used with…
In my application I have the following record:
TTransaction = record
Alias: string
Description: string
Creation: TDateTime
Count: Integer
end;
and I'm using this record in this array:
Transactions = array of TTransaction;
I'm keeping the…
Section 10.13, Destructors, of the C# Language Specification 3.0 states the following:
Destructors are not inherited. Thus, a class has no destructors other than the one which may be declared in that class.
The Destructors section of the C#…
My understanding of finalization is this:
To clean up or reclaim the memory that an object occupies, the Garbage collector comes into action. (automatically is invoked?)
The garbage collector then dereferences the object. Sometimes, there is no way…
Is there a way to obtain the total number of finalizers registered using runtime.SetFinalizer and which have not yet run?
We are considering adding a struct with a registered finalizer to some of our products to release memory allocated using…
Discussions of finalizable objects in Java typically discuss the common indirect costs that happen when finalizable objects (and their associated resources) cannot be quickly garbage collected.
I'm more interested, at the moment, in what the actual…
I am trying to find a safe/deterministic way to release an interface which is encapsulated in an OleVariant.
AFAICS Delphi releases interface references at the end of a procedure, but in my case I have to do it earlier, because I have to shut down…
I have some code that I suspect is leaking memory.
As the code uses ccall and maintains significant information held inside pointers,
which are supposed to be free'd by code that is ccalled during finalizers.
In my debugging I am calling gc().
And I…
I need to optimize my application in memory usage. so I used .net performance profiler...
but some references in my application are still alive and are never collected by GC even if I force it to collect.
The reference that is alive is a…
I need to execute my code after finalization of SysUtils unit.
I've placed my code in separate unit and included it first in uses clause of dpr-file, like this:
project Project1;
uses
MyUnit, // <- my separate unit
SysUtils,
Classes,
…
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".…