all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Display problems after lots of different (generated) images have been shown
@ 2007-08-19 19:52 Michael Schierl
  2007-08-19 21:00 ` Jason Rumney
  0 siblings, 1 reply; 3+ messages in thread
From: Michael Schierl @ 2007-08-19 19:52 UTC (permalink / raw)
  To: bug-gnu-emacs

Please describe exactly what actions triggered the bug
and the precise symptoms of the bug:


I have an eLisp file that dynamically generates XPM images and shows
them (25 at a time, and then they are removed from the buffer again).

After using Emacs for a while, it seems that Emacs has problems
redisplaying itself (not only the images, but also other graphical
elements display incorrectly).

If I still used Win98 I'd say it is a lack of GDI objects, but I am
using WinXP and do not think one could reach the GDI object limit there.

I am sure that I do not hold any stale references to these images, but
it seems that they still consume some kind of resources. Killing buffers
or running M-x garbage-collect does not help either.

The leak occurs both with xpm and xbm files (which are the only two
formats suitable for dynamic generation in my opinion). The problem does
not occur if the same image is shown over and over, only if images are
different.


To reproduce:


;; XPM
(let ((img-header "/* XPM */
\"8 8 8 1\"
\"0c #ff0000\" \"1c #00ff00\" \"2c #ffff00\" \"3c #0000ff\"
\"4c #ff00ff\" \"5c #00ffff\" \"6c #ffffff\" \"7c #ffffff\"")
      (img-template "\
\"00000000\" \"00000000\" \"00000000\" \"00000000\" \
\"00000000\" \"00000000\" \"00000000\" \"00000001\"")
      x y v)
  (random t)
  (dotimes (i 17000) ; >16384
    (setq x (random 8)
          y (random 8)
          v (random 8))
    ;; change image slightly
    (aset img-template (+ x (* y 11) 1) (+ ?0 v))
    ;; insert image
    (insert
     (propertize "x" 'display
                 `(image :type xpm
                         :data ,(concat img-header img-template))))
    (redisplay t)
    (delete-char -1)))


;; XBM
(let ((img-template (vector "a" "a" "a" "a" "a" "a" "a" "a"))
      x y)
  (random t)
  (dotimes (i 17000) ; > 16384
    (setq x (random 8)
          v (random 256))
    ;; change image slightly
    (aset img-template x (char-to-string v))
    ;; insert image
    (insert
     (propertize "x" 'display
                 `(image :type xbm :width 8 :height 8
                         :data ,img-template)))
    (redisplay t)
    (delete-char -1)))


In GNU Emacs 22.1.1 (i386-mingw-nt5.1.2600)
 of 2007-06-02 on RELEASE
Windowing system distributor `Microsoft Corp.', version 5.1.2600
configured using `configure --with-gcc (3.4) --cflags -Ic:/gnuwin32/include'

Important settings:
  value of $LC_ALL: nil
  value of $LC_COLLATE: nil
  value of $LC_CTYPE: nil
  value of $LC_MESSAGES: nil
  value of $LC_MONETARY: nil
  value of $LC_NUMERIC: nil
  value of $LC_TIME: nil
  value of $LANG: DEU
  locale-coding-system: cp1252
  default-enable-multibyte-characters: t

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

* Re: Display problems after lots of different (generated) images have been shown
  2007-08-19 19:52 Display problems after lots of different (generated) images have been shown Michael Schierl
@ 2007-08-19 21:00 ` Jason Rumney
  2007-08-19 21:28   ` Michael Schierl
  0 siblings, 1 reply; 3+ messages in thread
From: Jason Rumney @ 2007-08-19 21:00 UTC (permalink / raw)
  To: Michael Schierl; +Cc: bug-gnu-emacs

Michael Schierl wrote:
> If I still used Win98 I'd say it is a lack of GDI objects, but I am
> using WinXP and do not think one could reach the GDI object limit there.
>   

You can find out if this is the problem by starting the Task Manager
(Ctrl-Alt-Del) and while looking at the Processes tab, select the
"Select Columns..." option from the View menu. There should be an option
to show the number of GDI objects in use by each process. The limit on
XP seems to be 9999 per process (you do seem to be inserting more images
than that).

> I am sure that I do not hold any stale references to these images, but
> it seems that they still consume some kind of resources. Killing buffers
> or running M-x garbage-collect does not help either.
>   
Try M-: (clear-image-cache)

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

* Re: Display problems after lots of different (generated) images have been shown
  2007-08-19 21:00 ` Jason Rumney
@ 2007-08-19 21:28   ` Michael Schierl
  0 siblings, 0 replies; 3+ messages in thread
From: Michael Schierl @ 2007-08-19 21:28 UTC (permalink / raw)
  To: Jason Rumney; +Cc: bug-gnu-emacs

[forgot to put the list into CC:]

Jason Rumney schrieb:
>> Michael Schierl wrote:
>>>> If I still used Win98 I'd say it is a lack of GDI objects, but
>>>>  I am using WinXP and do not think one could reach the GDI 
>>>> object limit there.
>> 
>> You can find out if this is the problem by starting the Task 
>> Manager (Ctrl-Alt-Del) and while looking at the Processes tab, 
>> select the "Select Columns..." option from the View menu. There 
>> should be an option to show the number of GDI objects in use by 
>> each process. The limit on XP seems to be 9999 per process (you do
>>  seem to be inserting more images than that).

Thank you. For me it sometimes goes to 9999, and sometimes to 10000. (on
Win16 and "compatible" Win32 versions the limit was 16384 for all
processes together, which I reached regurlarly...)

>>>> I am sure that I do not hold any stale references to these 
>>>> images, but it seems that they still consume some kind of 
>>>> resources. Killing buffers or running M-x garbage-collect does
>>>> not help either.
>>>> 
>> Try M-: (clear-image-cache)

Thank you. This cures my problem. I reduced `image-cache-evicion-delay'
now, so most probably I won't run into that situation again.

However, the GDI object counter in task manager seems to wrap-around
when I clear the image cache; it shows 4294947622 (=0xFFFFB326)
afterwards. But that is most likely not a bug of Emacs :)


Michael

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

end of thread, other threads:[~2007-08-19 21:28 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-08-19 19:52 Display problems after lots of different (generated) images have been shown Michael Schierl
2007-08-19 21:00 ` Jason Rumney
2007-08-19 21:28   ` Michael Schierl

Code repositories for project(s) associated with this external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.