From: Yusuf Pisan

Subject: Running out of graphics heap

Date: 1997-5-29 9:00


An application that I am running is running out of graphics heap, or at
least that is what I think is happening.  I will try to replicate teh bug
with a small piece of code, but in them meantime I am open to suggestions
and work arounds.

Platform: Allegro CL 3.0.2 under Windows95

Problem:  The application has different toolbars it keeps switching
between.  After redisplaying it ~40 times all the icons turn blank.
Windows95 explorer and other applications also display blank icons,
programs start complaining about "not enough resources", "not enough
storage".  If I continue to use lisp, the system becomes unstable and has
to be rebooted.  If I exit lisp then most (but I don't think all) resources
are recovered.

I can reliably duplicate the bug with the piece of code below. My questions
are:

	* Has other people encountered this problem under Windows95/NT or other
platforms?

	* Is there a windows95 program to look at the graphics heap?  "wintop"
program shows the cpu idle and memory usage to be normal.

	* When is graphics heap allocated and how can it be freed?

Thank you for any help.  Any suggestion would be appreciated.  My current
work around is to have the same toolbar all the time which is not the best...


--
Yusuf Pisan
Northwestern University
The Institute for the Learning Sciences
Qualitative Reasoning Group
<nwu.edu at mailto:y-pisan>
http://www.cs.nwu.edu/~yusuf/

;;;;
---------------------------------------------------------------------------

(defun test-leak ()
  (dotimes (i 1000)
     (format t "~A " i)
     (set-focus *lisp-main-window*)
     (set-focus (front-window (frame-child (frame-window *MY-GUI*))))))

;; The relevant method called by set-focus after method is given below

(defmethod realize ((manager toolbar-manager-mixin))
   "Refreshes the toolbar on the manager's display window."
   (when (toolbar-items manager)
      (unless (toolbar manager)
         (setf (toolbar manager)
               (make-tool-bar manager :name (object-name manager)))
         (realize-toolbar-items (toolbar manager) 
           (apply 'create-toolbar-item-list manager (toolbar-items manager))))
      (when (and (toolbar manager) (open-stream-p (toolbar manager)))
         (assert-toolbar manager (toolbar manager))))
   (when (next-method-p)
      (call-next-method)))

(defmethod assert-toolbar ((manager toolbar-manager-mixin) toolbar)
   (when (and (toolbar-display-window manager) 
              (open-stream-p (toolbar-display-window manager)))
      (let* ((tdw (toolbar-display-window manager))
             (wtw (window-toolbars tdw)))
         (cond (wtw
                 (let ((dialog-item (car (dialog-items (car wtw))))
                       (new-value (dialog-item-range 
                                    (car (dialog-items toolbar)))))
                    (set-dialog-item-range dialog-item new-value)
                 ))
               (t (add-toolbar-to-window tdw toolbar))))))