[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Hash table GC
From: |
Eli Zaretskii |
Subject: |
Re: Hash table GC |
Date: |
Tue, 15 Oct 2024 15:33:33 +0300 |
> From: Anand Tamariya <atamariya@gmail.com>
> Date: Tue, 15 Oct 2024 13:18:10 +0530
> Cc: emacs-devel@gnu.org
>
> I'm trying to use a hash table for storing parsed CSS values. I'm seeing a
> degradation in performance
> (memory and CPU) over a period of time. Trying to investigate how to fix the
> same. Below is a minimal
> example:
>
> (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.
So I think you should not use 'key-or-value if you want the table to
be GCed. E.g., why not use t instead?