Common lisp 在CLIM中,如何以正确的方式在应用程序窗格上显示图像?

Common lisp 在CLIM中,如何以正确的方式在应用程序窗格上显示图像?,common-lisp,sbcl,clim,Common Lisp,Sbcl,Clim,我尝试了“图像查看器”示例中编写的方法,但当我运行该示例时,程序会泄漏内存。每次调用函数绘图模式*时,(房间)报告的内存都会增加,最终SBCL内存耗尽,游戏结束 我用位图文件中的make pattern创建图案,然后用draw pattern*显示它。守则如下: (ql:quickload 'mcclim) (ql:quickload 'mcclim-gif-bitmaps) (defpackage #:display-image (:use #:clim #:clim-lisp)) (

我尝试了“图像查看器”示例中编写的方法,但当我运行该示例时,程序会泄漏内存。每次调用函数绘图模式*时,(房间)报告的内存都会增加,最终SBCL内存耗尽,游戏结束

我用位图文件中的make pattern创建图案,然后用draw pattern*显示它。守则如下:

(ql:quickload 'mcclim)
(ql:quickload 'mcclim-gif-bitmaps)

(defpackage #:display-image
  (:use #:clim #:clim-lisp))

(in-package #:display-image)

(define-application-frame img-viewer ()
  ((img-pattern :initform 'nil))
  (:panes
   (int-pane (make-clim-interactor-pane :name 'interactor))
   (canvas-pane (make-clim-application-pane
         :name 'canvas
         :scroll-bars t
         :display-time :command-loop
         :display-function #'draw-image)))
  (:layouts
   (default
       (vertically (:min-height 650 :max-height 800)
         (3/4 (labelling (:label "Image") canvas-pane))
         (1/4 int-pane))))
  (:menu-bar t))

(defmethod draw-image ((frame img-viewer) stream)
  (with-slots (img-pattern) *application-frame*
    (if img-pattern
        (draw-pattern* stream img-pattern
               (/ (- (bounding-rectangle-width stream)
                     (pattern-width img-pattern)) 2)
               0))))

(define-img-viewer-command (com-quit :name t :menu t) ()
  (frame-exit *application-frame*))

(define-img-viewer-command (com-change-img :name t :menu t)
    ((img-pathname 'pathname
           :default (user-homedir-pathname)
           :insert-default t))
  (if (and (probe-file img-pathname)
           (string= "GIF" (string-upcase (pathname-type img-pathname))))
      (with-slots (img-pattern) *application-frame*
        (setf img-pattern
              (make-pattern-from-bitmap-file img-pathname
                                             :format :gif)))))

(run-frame-top-level (make-application-frame 'img-viewer)

您是否用另一个lisp尝试了您的示例?也许这是SBCL的一个问题。你能建议一个实施方案吗?我最近尝试了CMUCL,但是编译过程被CLX的负载卡住了。此外,ECL不能定期加载mcclim.asdI use,它适用于Linux、Windows、Mac,我对此很满意。我尝试了CCL,代码运行了,但我注意到与SBCL相同的行为。使用的内存越来越多。