[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Hash table GC
From: |
Tassilo Horn |
Subject: |
Re: Hash table GC |
Date: |
Tue, 15 Oct 2024 15:07:55 +0200 |
User-agent: |
mu4e 1.12.6; emacs 31.0.50 |
Eli Zaretskii <eliz@gnu.org> writes:
>> (dotimes (i 10000)
>> (let* ((a (make-hash-table :test 'equal :weakness 'key-or-value))
>> (j 0))
>> (dolist (prop '(padding margin margin-top border
>> color background background-color display
>> width height clear
>> font font-size font-style font-weight))
>> (puthash j (list prop (setq j (1+ j))) a))
>> (pp a)
>> ))
>
> You are using 'key-or-value, which prevents the table from being GCed
> of _either_ key or value cannot be GCed. And your keys are symbols,
> so they are not GCed.
Really? I would assume that in a table with :weakness 'key-or-value the
*entries* can be removed/GCed if there are no references to either the
entry's key or value. But the whole table should still be GCed if
there's no reference to the table itself. So in the above example, I'd
think that `a' is GC-able immediately after the `let*`.
Running the above many times doesn't seem to increase my Emacs memory
footprint so my statement feels right.
Bye,
Tassilo