[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: frames vs. weak hash tables and garbage collection
From: |
Joe Wells |
Subject: |
Re: frames vs. weak hash tables and garbage collection |
Date: |
Fri, 31 Aug 2007 16:15:00 +0100 |
User-agent: |
Gnus/5.11 (Gnus v5.11) Emacs/22.1 (gnu/linux) |
Thien-Thi Nguyen <ttn@gnuvola.org> writes:
> () Joe Wells <jbw@macs.hw.ac.uk>
> () Thu, 30 Aug 2007 02:27:32 +0100
>
> ;; The only reference to the new frame is now the key in the hash
> ;; table. Because of the weakness, this key should not keep the
> ;; frame alive.
>
> there's a lot of stuff going on w/ make-frame.
>
> try replacing `(make-frame)' with:
>
> (x-create-frame-with-faces)
>
> here, i see that `reproduce-bug' returns nil.
> what do you see?
It doesn't help me to even replace make-frame with x-create-frame (the
primitive used by x-create-frame-with-faces).
Are you able to reproduce the bug at all with the code I originally
sent?
Thien-Thi Nguyen <ttn@gnuvola.org> writes:
> another thing: one gc pass may not be enough.
> i see (reproduce-bug) => nil only at:
>
> (dotimes (i N)
> (garbage-collect))
>
> where (< 1 N). my emacs is tweaked, however (ymmv).
Running garbage-collect 10 times makes no difference for me.
Here is the code I am now using to reproduce the bug:
(defun reproduce-bug ()
(let ((ht (make-hash-table :weakness 'key)))
(let* (after-make-frame-functions
(x
(x-create-frame nil)
;;(x-create-frame-with-faces)
;;(make-frame)
;;(get-buffer-create "xyzzy")
))
(puthash x t ht)
(delete-frame x)
;;(kill-buffer x)
)
;; The only reference to the new frame is now the key in the hash
;; table. Because of the weakness, this key should not keep the
;; frame alive.
(loop repeat 10 do (garbage-collect))
;; The hash table should now be empty.
(let (l)
(maphash (lambda (k v) (push (cons k v) l)) ht)
l)))
With the above definition, I still get (reproduce-bug) returning
((#<dead frame emacs@localhost.localdomain 0xa2ae808> . t)) instead of
nil.
--
Joe