finalization

Why code in any unit finalization section of a package is not executed at shut down?

徘徊边缘 提交于 2020-06-25 18:46:25
问题 I have an application that uses statically-linked runtime packages as well as designtime packages that use them. For some reason the code in any unit finalization section is not being run at runtime (I can't tell when this started happening). finalization ShowMessage('Goodbye'); end. Shutting Delphi down shows the message, but not when my application shuts down. It gets weirder in that if I put a breakpoint on ShowMessage, it breaks there but does not execute the line. If there are multiple

What is the up-front cost of an object being finalizable?

非 Y 不嫁゛ 提交于 2020-01-23 05:18:28
问题 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 direct cost of being finalizable is, both in memory terms, and in object allocation time. I've seen oblique references to the existence of such a cost in a number of places, for example, Oracle's article on finalization memory retention issues

How to list all object in GC finalization list?

て烟熏妆下的殇ゞ 提交于 2020-01-03 17:27:25
问题 I have crash in my program, it is a visualizer for VS, so, it is very hard to debug it, i have tried to make dump and use WinDbg to study it, but it unsuccessful. So, now i try to put my hands on that list programmatically, but i don't know how. Thanks. 回答1: I do not think that there is a way to get at the finalization queue via .NET's managed Framework Class Library (FCL). I suspect that if you want to do this programmatically instead of debugging with WinDbg, you (just like WinDbg and

How to list all object in GC finalization list?

天涯浪子 提交于 2020-01-03 17:26:12
问题 I have crash in my program, it is a visualizer for VS, so, it is very hard to debug it, i have tried to make dump and use WinDbg to study it, but it unsuccessful. So, now i try to put my hands on that list programmatically, but i don't know how. Thanks. 回答1: I do not think that there is a way to get at the finalization queue via .NET's managed Framework Class Library (FCL). I suspect that if you want to do this programmatically instead of debugging with WinDbg, you (just like WinDbg and

Delphi and finalization in a unit

寵の児 提交于 2019-12-22 07:50:11
问题 I have two units unitA and unitB. Class TFoo is declared in unitB. Is it allways safe to call B.Free in finalization of unitA? How does it depend on in which order unitA and unitB are in dpr? Can I be sure that unitB exists when unitA finalization is executed? unit unitB; interface type TFoo = class // code... end; // code.... end; unit unitA; // code.. implementation uses unitB; var A: TStringList; B: UnitB.TFoo; initialization A:= TStringList.Create; B:= UnitB.TFoo.Create; finalization A

Unit finalization order for application, compiled with run-time packages?

青春壹個敷衍的年華 提交于 2019-12-09 18:05:51
问题 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, SomeOtherUnits; procedure Test; begin // end; begin SetProc(Test); end. MyUnit looks like this: unit MyUnit; interface procedure SetProc(AProc: TProcedure); implementation var Test: TProcedure; procedure SetProc(AProc: TProcedure); begin Test := AProc; end;

Finalizer launched while its object was still being used

点点圈 提交于 2019-12-06 04:30:47
问题 Summary: C#/.NET is supposed to be garbage collected. C# has a destructor, used to clean resources. What happen when an object A is garbage collected the same line I try to clone one of its variable members? Apparently, on multiprocessors, sometimes, the garbage collector wins... The problem Today, on a training session on C#, the teacher showed us some code which contained a bug only when run on multiprocessors. I'll summarize to say that sometimes, the compiler or the JIT screws up by

Delphi and finalization in a unit

梦想与她 提交于 2019-12-05 16:02:17
I have two units unitA and unitB. Class TFoo is declared in unitB. Is it allways safe to call B.Free in finalization of unitA? How does it depend on in which order unitA and unitB are in dpr? Can I be sure that unitB exists when unitA finalization is executed? unit unitB; interface type TFoo = class // code... end; // code.... end; unit unitA; // code.. implementation uses unitB; var A: TStringList; B: UnitB.TFoo; initialization A:= TStringList.Create; B:= UnitB.TFoo.Create; finalization A.Free; B.Free; // Is it safe to call? end. Jim McKeeth Yes, you should be fine since B is created in Unit

Memory leak in VB

∥☆過路亽.° 提交于 2019-12-04 06:35:35
问题 We noticed one interesting issue regarding memory management in VB that we do not understand. If anyone could help us with this one, please do. We have a simple class with one single event. We create and destroy 5000 instances of this class and before we run a test we read the process memory usage. At the end we force GC and check the memory again.What we noticed is, that we have a constant memory growing. We did the same sample in C# and we did not run into this issue. Now here is the wired

Unit finalization order for application, compiled with run-time packages?

老子叫甜甜 提交于 2019-12-04 05:30:47
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, SomeOtherUnits; procedure Test; begin // end; begin SetProc(Test); end. MyUnit looks like this: unit MyUnit; interface procedure SetProc(AProc: TProcedure); implementation var Test: TProcedure; procedure SetProc(AProc: TProcedure); begin Test := AProc; end; initialization finalization Test; end. Note that MyUnit doesn't have any uses. This is usual Windows exe, no