Changeset 12716


Ignore:
Timestamp:
Aug 29, 2009, 7:38:20 PM (10 years ago)
Author:
gz
Message:

Add show-malloc-info (from gb)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/working-0711/ccl/library/leaks.lisp

    r12711 r12716  
    283283    (ccl::rref mallinfo :mallinfo.uordblks)))
    284284
     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
    285328)  ;; end of linux-only code
Note: See TracChangeset for help on using the changeset viewer.