Ignore:
Timestamp:
Oct 15, 2009, 6:48:26 PM (11 years ago)
Author:
rme
Message:

Trunk changes r12910 through r13030 (need to update interfaces separately).

Location:
release/1.4/source/library
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • release/1.4/source/library/leaks.lisp

    r11373 r13031  
    235235  (with-open-file (s log-file)
    236236    (let ((hash (make-hash-table :test 'equal))
     237          (free-list '())
    237238          (eof (list :eof)))
    238239      (loop for line = (read-line s nil eof)
     
    242243              do
    243244           (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))))
    246247             (cond (plus-pos
    247248                    (let* ((where (subseq line 0 plus-pos))
     
    252253                      (setf (gethash addr hash) (list where size))))
    253254                   (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)))))))
    256261      (let ((res nil))
    257262        (maphash (lambda (key value)
    258263                   (push (append value (list key)) res))
    259264                 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)))))
    261278
    262279;; Return the total number of bytes allocated by malloc()
     
    266283    (ccl::rref mallinfo :mallinfo.uordblks)))
    267284
     285#||
     286http://www.gnu.org/s/libc/manual/html_node/Statistics-of-Malloc.html
     287
     288int arena
     289    This is the total size of memory allocated with sbrk by malloc, in bytes.
     290int ordblks
     291    This is the number of chunks not in use. (The memory allocator internally gets chunks of memory from the operating system, and then carves them up to satisfy individual malloc requests; see Efficiency and Malloc.)
     292int smblks
     293    This field is unused.
     294int hblks
     295    This is the total number of chunks allocated with mmap.
     296int hblkhd
     297    This is the total size of memory allocated with mmap, in bytes.
     298int usmblks
     299    This field is unused.
     300int fsmblks
     301    This field is unused.
     302int uordblks
     303    This is the total size of memory occupied by chunks handed out by malloc.
     304int fordblks
     305    This is the total size of memory occupied by free (not in use) chunks.
     306int keepcost
     307    This is the size of the top-most releasable chunk that normally borders the end of the heap (i.e., the high end of the virtual address space's data segment).
     308||#   
     309
     310(defun show-malloc-info ()
     311  (rlet ((info :mallinfo))
     312    (#_mallinfo info)                   ;struct return invisible arg.
     313    (let* ((arena (pref info :mallinfo.arena))
     314           (ordblks (pref info :mallinfo.ordblks))
     315           (hblks (pref info :mallinfo.hblks))
     316           (hblkhd (pref info :mallinfo.hblkhd))
     317           (uordblks (pref info :mallinfo.uordblks))
     318           (fordblks (pref info :mallinfo.fordblks))
     319           (keepcost (pref info :mallinfo.keepcost)))
     320      (format t "~& arena size: ~d/#x~x" arena arena)
     321      (format t "~& number of unused chunks = ~d" ordblks)
     322      (format t "~& number of mmap'ed chunks = ~d" hblks)
     323      (format t "~& total size of mmap'ed chunks = ~d/#x~x" hblkhd hblkhd)
     324      (format t "~& total size of malloc'ed chunks = ~d/#x~x" uordblks uordblks)
     325      (format t "~& total size of free chunks = ~d/#x~x" fordblks fordblks)
     326      (format t "~& size of releaseable chunk = ~d/#x~x" keepcost keepcost))))
     327
    268328)  ;; end of linux-only code
  • release/1.4/source/library/x86-win64-syscalls.lisp

    • Property svn:executable deleted
Note: See TracChangeset for help on using the changeset viewer.