Changeset 12711
- Timestamp:
- Aug 28, 2009, 1:45:18 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/working-0711/ccl/library/leaks.lisp
r12339 r12711 235 235 (with-open-file (s log-file) 236 236 (let ((hash (make-hash-table :test 'equal)) 237 (free-list '()) 237 238 (eof (list :eof))) 238 239 (loop for line = (read-line s nil eof) … … 242 243 do 243 244 (setf line (subseq line 2)) 244 (let ((plus-pos ( search " + " line))245 (minus-pos ( search " - " line)))245 (let ((plus-pos (or (search " + " line) (search " > " line))) 246 (minus-pos (or (search " - " line) (search " < " line)))) 246 247 (cond (plus-pos 247 248 (let* ((where (subseq line 0 plus-pos)) … … 252 253 (setf (gethash addr hash) (list where size)))) 253 254 (minus-pos 254 (let ((addr (subseq line (+ minus-pos 3)))) 255 (remhash addr hash)))))) 255 (let* ((where (subseq line 0 minus-pos)) 256 (addr (subseq line (+ minus-pos 3))) 257 (found (nth-value 1 (gethash addr hash)))) 258 (if found 259 (remhash addr hash) 260 (push (list where addr) free-list))))))) 256 261 (let ((res nil)) 257 262 (maphash (lambda (key value) 258 263 (push (append value (list key)) res)) 259 264 hash) 260 res)))) 265 (values res free-list))))) 266 267 (defun pretty-print-mtrace-summary (file) 268 (let* ((malloc-sum 0)) 269 (multiple-value-bind (mallocs frees) (parse-mtrace-log file) 270 (dolist (i mallocs) 271 (incf malloc-sum (parse-integer (second i) :radix 16 :start 2)) 272 (format t "~&~A" i)) 273 (format t "~&Freed but not malloced:~%~{~A~%~}" frees) 274 (format t "~&total-malloc-not-freed: ~~A ~A free not malloc: ~A" 275 (/ malloc-sum 1024.0) 276 (length mallocs) 277 (length frees))))) 261 278 262 279 ;; Return the total number of bytes allocated by malloc()
Note: See TracChangeset
for help on using the changeset viewer.