harmony-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Geir Magnusson Jr." <g...@pobox.com>
Subject Re: [drlvm] finalizer design questions
Date Wed, 27 Dec 2006 10:35:20 GMT

On Dec 26, 2006, at 8:30 PM, Xiao-Feng Li wrote:

> On 12/27/06, Geir Magnusson Jr. <geir@pobox.com> wrote:
>>
>> On Dec 26, 2006, at 10:53 AM, Weldon Washburn wrote:
>>
>>
>> >
>> > 5)
>> > How are real java apps designed?  What do they really use finalizer
>> > for?
>>
>> I don't believe that people use them anymore.  When I was writing
>> real things in Java, I never used them - I made sure that resource
>> management and such was deliberate, and not dependent upon when and
>> if (and even where - it can run in any thread, right?) the finalizer
>> ran.
>
> Yes, it's encouraged not to use finalizer at all  in Java app, or
> discouraged to use it. The idea to put resource management in
> finalizer then give up the control is problematic. At the same time,
> the finalization subsystem takes all the responsility of resource
> management and works to avoid all the app design issues is unfair. It
> is ultimately impossible unless the finalization system deeply
> involves with the app activity (such as what Pavel Afremov said to
> identify the "good" app threads), but then the finalization subsystem
> knows too much about the app internals, and virually part of the app
> in semantics. If that's the only way to make the finalization
> subsystem really work, I would choose to manage the resources in app
> directly, not to use finalizers at the beginning.

Right - the finalizer can't actually know.

>
> If in very rare cases some apps indeed have undesirable finalizer
> behavior, we can take two actions at the same time with priority
> order: 1. to tell the programmer that his design has some unexpected
> finalizers and suggest to change the design, 2. if the app is
> important, we can afford some time to study its behavior and think of
> some solution in our VM.

Why can't we simply mimic the rational behavior of the RI and other  
production VMs and leave it at that?

geir




Mime
View raw message