There is an apparent memory leak in the latest released Win32 SBCL (1.0.22)
that manifests itself in a small OpenGL test app I wrote. I'm running
Windows XP Professional Service Pack 3. You can download the test app here:
simply extract it then execute "run.bat". The test case makes two
1) that SBCL is in your system path. i.e. if you open a console window and
type "sbcl", that should run SBCL 1.0.22, and shouldn't cause an error like
"'sbcl' is not recognized as an internal or external command".
2) that "opengl32.dll" is also in your system path. It should typically be
located at C:\Windows\System32\opengl32.dll.
When the program starts, the background should flash random colors and there
should be a white quad in the center of the screen, such as in:
The app will begin to leak memory at approximately 30KB/sec. After awhile
(and after consuming a few megs), the leak will "settle down" somewhat in
that it will only leak memory at approximately 4KB/s. After a long period
of time, the memory leak appears to subside (the leak rate will eventually
decline to less than 4KB/minute, which is rather insignificant).
The program's main loop is very simple:
(defun main-loop ()
Both 'glut-post-redisplay' and 'glut-main-loop-event' are foreign GLUT
functions, which are defined as follows:
(sb-alien:define-alien-routine ("glutPostRedisplay" glut-post-redisplay)
(sb-alien:define-alien-routine ("glutMainLoopEvent" glut-main-loop-event)
I have confirmed that those external functions don't leak memory in my other
pure-C++ test app.
How should I go about fixing this? Does the memory leak occur because I
wrote the program itself incorrectly, or because of a bug internal to SBCL?
(Could it be something like, SBCL isn't performing tail call optimization
on 'main-loop' and so the program's stack is growing infinitely large?)
Also, this is one of my first Lisp programs, so I apologize for any errors
or nonstandard conventions in the source code. It is reasonably
Thank you. I very much appreciate your time.
-- Shawn Presser