Changeset 12938 for trunk/source/library


Ignore:
Timestamp:
Oct 9, 2009, 2:18:15 PM (10 years ago)
Author:
gz
Message:

Add show-malloc-info (from gb)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/source/library/leaks.lisp

    r11373 r12938  
    266266    (ccl::rref mallinfo :mallinfo.uordblks)))
    267267
     268#||
     269http://www.gnu.org/s/libc/manual/html_node/Statistics-of-Malloc.html
     270
     271int arena
     272    This is the total size of memory allocated with sbrk by malloc, in bytes.
     273int ordblks
     274    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.)
     275int smblks
     276    This field is unused.
     277int hblks
     278    This is the total number of chunks allocated with mmap.
     279int hblkhd
     280    This is the total size of memory allocated with mmap, in bytes.
     281int usmblks
     282    This field is unused.
     283int fsmblks
     284    This field is unused.
     285int uordblks
     286    This is the total size of memory occupied by chunks handed out by malloc.
     287int fordblks
     288    This is the total size of memory occupied by free (not in use) chunks.
     289int keepcost
     290    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).
     291||#   
     292
     293(defun show-malloc-info ()
     294  (rlet ((info :mallinfo))
     295    (#_mallinfo info)                   ;struct return invisible arg.
     296    (let* ((arena (pref info :mallinfo.arena))
     297           (ordblks (pref info :mallinfo.ordblks))
     298           (hblks (pref info :mallinfo.hblks))
     299           (hblkhd (pref info :mallinfo.hblkhd))
     300           (uordblks (pref info :mallinfo.uordblks))
     301           (fordblks (pref info :mallinfo.fordblks))
     302           (keepcost (pref info :mallinfo.keepcost)))
     303      (format t "~& arena size: ~d/#x~x" arena arena)
     304      (format t "~& number of unused chunks = ~d" ordblks)
     305      (format t "~& number of mmap'ed chunks = ~d" hblks)
     306      (format t "~& total size of mmap'ed chunks = ~d/#x~x" hblkhd hblkhd)
     307      (format t "~& total size of malloc'ed chunks = ~d/#x~x" uordblks uordblks)
     308      (format t "~& total size of free chunks = ~d/#x~x" fordblks fordblks)
     309      (format t "~& size of releaseable chunk = ~d/#x~x" keepcost keepcost))))
     310
    268311)  ;; end of linux-only code
Note: See TracChangeset for help on using the changeset viewer.