Can I measure how much memory an object consumes?




I am developing a small web application using Hunchentoot. It is
currently running in a VMWare instance with Ubuntu as the guest OS and
Windows XP as host. Because it runs on my machine I have given the
instance 300 MB memory.

Now I am thinking of logging the latest X requests in a global
variable, to make debugging easy if error reports from users comes
in. I was thinking of maybe saving the last 100 or so, but due to the
limited memory I have, I would like to know if there is a way for me
to calculate or measure how much memory these 100 request objects will
consume, to see if this is feasible. Is there? Other than running
`top' and
watching the memory consumption increase, that is.

I am using the latest SBCL available in Ubuntu 8.04.

Thanks!

/Mathias

PS. To keep only the last X requests stored, I wrote a couple of
"ring" functions. If anyone have suggestions on a better data
structure to save this in, please let me know:

(defun make-ring (len)
(cons 0 (make-array len)))

(defun ring-push (ring item)
(let ((vec (cdr ring))
(idx (car ring)))
(setf (aref vec idx) item)
(setf (car ring) (mod (1+ idx) (length vec)))))

(defun ring-pop (ring)
(let ((vec (cdr ring))
(idx (car ring)))
(setf (car ring) (mod (- (+ idx (length vec)) 1) (length vec)))
(aref vec (car ring))))

(defvar *requests*)

(setf *requests* (make-ring 10))

And I call it like this:

(ring-push *requests* *request*)
.



Relevant Pages

  • Re: stress-testing erlang
    ... >> Just thought I'd report some benchmarks running 64-bit erlang on ... Running a simple ring benchmark, ... The OS process used 1.3G of virtual memory. ...
    (comp.lang.functional)
  • Re: [PATCH v3 1/7] AMSO1100 Low Level Driver.
    ... this memory is used to describe the tx ring from the host's ... The HW never touches this memory. ... the RX descriptor ring and get new ones that sufficient for the new MTU. ... To effectively flush that cached address of the old skb, ...
    (Linux-Kernel)
  • Re: Capabilities and sandboxed sublanguages.
    ... you do this just annotate how much memory it uses. ... This would even allow, for example, limits on number ... of objects, number of lists, special functions ... Ring the bells that still can ring. ...
    (comp.lang.lisp)
  • Re: Just a question
    ... >>> your team is a shit team...until you get a ring you keep your fucking ... And thanks for the memory ... Books that we enjoyed ... But forgot that roses die ...
    (alt.sports.football.pro.phila-eagles)