emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: using finalizers


From: Tomas Hlavaty
Subject: Re: using finalizers
Date: Sat, 01 Jan 2022 18:37:30 +0100

On Fri 31 Dec 2021 at 11:21, Stefan Monnier <monnier@iro.umontreal.ca> wrote:
> Rudolf Schlatte [2021-12-31 15:23:32] wrote:
>
>> Tomas Hlavaty <tom@logand.com> writes:
>>>
>>> I can see these cases where garbage collection might not do its job:
>>>
>>> 1. imprecise gc
>>>
>>> 2. program exit or abort
>>>
>>> 3. a leak to be fixed
>>
>> 4. the gc is generational and the object is in an old generation
>>
>> 5. the gc is incremental and didn't get around to the object yet
>>
>> ... etc
>>
>> I'm sure you knew this already, but in general, using gc for non-memory
>> resource management (e.g., "please close this file when this Lisp object
>> is GCed") is not a good idea--depending on the GC behavior, you'll run
>> out of file handles or whatnot.  The RAII pattern in C++
>> deterministically calls a destructor when a stack-allocated object goes
>> out of scope; in Lisp, the various `with-foo' macros serve the same
>> purpose.
>
> But the context here is a "bug report" about a finalizer not being
> called and it seemed pretty clear that the call to `garbage-collect` was
> just there to try and make the bug more apparent, not because the real
> ELisp code relies on the finalizer being called right at the first call
> to `garbage-collect` after the object became unreachable.

yes, that was the original issue



reply via email to

[Prev in Thread] Current Thread [Next in Thread]