unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* frames vs. weak hash tables and garbage collection
@ 2007-08-30  1:27 Joe Wells
  2007-08-30  2:07 ` Eric Hanchrow
                   ` (3 more replies)
  0 siblings, 4 replies; 23+ messages in thread
From: Joe Wells @ 2007-08-30  1:27 UTC (permalink / raw)
  To: bug-gnu-emacs

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

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

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

  ((#<dead frame emacs@localhost.localdomain 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.

Joe

======================================================================
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

^ permalink raw reply	[flat|nested] 23+ messages in thread

end of thread, other threads:[~2007-09-30 12:55 UTC | newest]

Thread overview: 23+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-08-30  1:27 frames vs. weak hash tables and garbage collection Joe Wells
2007-08-30  2:07 ` Eric Hanchrow
2007-08-30  3:00 ` Thien-Thi Nguyen
2007-08-30  3:07 ` Thien-Thi Nguyen
     [not found] ` <mailman.47.1188442895.18990.bug-gnu-emacs@gnu.org>
2007-08-31 15:15   ` Joe Wells
2007-08-31 15:42     ` Thien-Thi Nguyen
2007-08-31 15:50     ` Thien-Thi Nguyen
     [not found]     ` <mailman.116.1188575498.18990.bug-gnu-emacs@gnu.org>
     [not found]       ` <xnjir6tyj35.fsf@csb.bu.edu>
2007-09-02  2:00         ` Thien-Thi Nguyen
     [not found]     ` <mailman.115.1188574978.18990.bug-gnu-emacs@gnu.org>
     [not found]       ` <xnjhcmdyirv.fsf@csb.bu.edu>
2007-09-02  2:13         ` Thien-Thi Nguyen
2007-09-25 23:23     ` Joe Wells
2007-09-27  7:20       ` Glenn Morris
2007-09-27  8:50         ` Thien-Thi Nguyen
     [not found]           ` <mailman.1408.1190931512.18990.bug-gnu-emacs@gnu.org>
2007-09-28 14:34             ` Stefan Monnier
2007-09-28 14:56               ` Joe Wells
2007-09-28 16:27                 ` Stefan Monnier
2007-09-28 16:50                   ` Joe Wells
2007-09-28 18:22                     ` Stefan Monnier
2007-09-28 18:48                       ` Joe Wells
2007-09-29 16:10                   ` Richard Stallman
2007-09-29 16:20                     ` Joe Wells
2007-09-29 18:28                       ` Stefan Monnier
2007-09-29 19:25                         ` Drew Adams
2007-09-30 12:55                           ` Richard Stallman

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).