emacs-devel
[Top][All Lists]
Advanced

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

Re: using finalizers


From: Rudolf Schlatte
Subject: Re: using finalizers
Date: Fri, 31 Dec 2021 15:23:32 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (darwin)

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.




reply via email to

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