Skip to content

Instantly share code, notes, and snippets.

@tkf
Created January 30, 2012 08:22
Show Gist options
  • Save tkf/1703325 to your computer and use it in GitHub Desktop.
Save tkf/1703325 to your computer and use it in GitHub Desktop.

Quick profile of lexical-let memory leak

do-collect.el:

image

do-collect-with-gc.el:

image

lambda-in-let.el

image

lambda-in-let-with-gc.el

image

(require 'cl)
(defvar num-loop-1 30)
(defvar num-loop-2 100000)
(loop for i from 1 to num-loop-1 do
(loop for j from 1 to num-loop-2 collect
(lexical-let ((x `(,i ,j))) x))
(garbage-collect))
(require 'cl)
(defvar num-loop-1 30)
(defvar num-loop-2 100000)
(loop for i from 1 to num-loop-1 do
(loop for j from 1 to num-loop-2 collect
(lexical-let ((x `(,i ,j))) x)))
(require 'cl)
(defvar num-loop-1 30)
(defvar num-loop-2 100000)
(loop for i from 1 to num-loop-1 do
(loop for j from 1 to num-loop-2 collect
(lexical-let ((x `(,i ,j))) (lambda () x)))
(garbage-collect))
(require 'cl)
(defvar num-loop-1 30)
(defvar num-loop-2 100000)
(loop for i from 1 to num-loop-1 do
(loop for j from 1 to num-loop-2 collect
(lexical-let ((x `(,i ,j))) (lambda () x))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment