[Top][All Lists]

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

frames vs. weak hash tables and garbage collection

From: Joe Wells
Subject: frames vs. weak hash tables and garbage collection
Date: Thu, 30 Aug 2007 02:27:32 +0100
User-agent: Gnus/5.11 (Gnus v5.11) Emacs/22.1 (gnu/linux)

In a fresh “emacs -Q”, define this function:

  (defun reproduce-bug ()
    (let ((ht (make-hash-table :weakness 'key)))
      (let ((x
             ;;(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.
      ;; The hash table should now be empty.
      (let (l)
        (maphash (lambda (k v) (push (cons k v) l)) ht)

Then evaluating (reproduce-bug) will produce a result like this:

  ((#<dead frame address@hidden 0x88e2278> . t))

It should instead return nil.

If I replace the calls to make-frame and delete-frame by calls to
get-buffer-create and kill-buffer (see commented out lines above),
things work properly.  So this verifies that weak hash tables work at
least for some data types.

There are two possibilities that occur to me:

1. Maybe frames are simply not being garbage collected at all.

2. Maybe the feature of weak keys in hash tables doesn't work for the
   particular case of frames.

I hope this bug report is helpful.


In GNU Emacs 22.1.1 (i686-pc-linux-gnu, GTK+ Version 2.8.20)
 of 2007-06-27 on artemis
Windowing system distributor `The X.Org Foundation', version 11.0.70000000
configured using `configure  '--prefix=/home/jbw/local2' '--enable-debug' 
'--disable-nls' '--with-x-toolkit=gtk' 'CFLAGS=-O0 -g3 -ggdb''

Important settings:
  value of $LC_ALL: nil
  value of $LC_COLLATE: nil
  value of $LC_CTYPE: en_US.UTF-8
  value of $LC_MESSAGES: nil
  value of $LC_MONETARY: nil
  value of $LC_NUMERIC: nil
  value of $LC_TIME: jbw
  value of $LANG: nil
  locale-coding-system: utf-8
  default-enable-multibyte-characters: t

Major mode: Emacs-Lisp

Minor modes in effect:
  tooltip-mode: t
  tool-bar-mode: t
  mouse-wheel-mode: t
  menu-bar-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  blink-cursor-mode: t
  unify-8859-on-encoding-mode: t
  utf-translate-cjk-mode: t
  auto-compression-mode: t
  line-number-mode: t

reply via email to

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