[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Garbage collect and buffer-undo-list
From: |
Yuan Fu |
Subject: |
Re: Garbage collect and buffer-undo-list |
Date: |
Sat, 13 Mar 2021 14:16:32 -0500 |
> On Mar 13, 2021, at 2:01 PM, Stefan Monnier <monnier@iro.umontreal.ca> wrote:
>
>> I know the garbage collector trims buffer-undo-list. Does it collect the
>> cons cell if there are other references to that object (other than
>> buffer-undo-list)?
>
> No, it can't.
>
> If you want to keep a reference to some of those cons-cells but still
> want the GC to collect them when the undo-log is trimmed, then you need
> to use a weak reference. We don't currently have plain "weak
> references" in ELisp, but we do have hash-tables whose keys and/or
> values can be weak references (that's what I used in
> `undo-equiv-table`).
>
That’s cool, I do want the referenced object to survive. Thanks!
Yuan