On Mon, May 26, 2003 at 09:11:59PM +0900, Brian Candler wrote:
> On Mon, May 26, 2003 at 06:29:23PM +0900, Xiangrong Fang wrote:
> > I have no good way to measure this. What I did is to watch the *total*
> > memory required by the program, with or without the hash. I don't know
> > if there is a way to do what you mentioned. May be some ruby experts
> > know?
> 
> You are probably creating a lot of temporary garbage objects, so you're
> measuring the size of hash + garbage pool.
> 
> You could try 'GC.start' to do garbage collection, but I don't know if Ruby
> then un-mallocs the storage and returns it to the O/S.

It does free() the space. Whether or not it's returned to the OS depends
on stdlib.

Maybe you could add some printf statements in obj_free (gc.c) and
st_free_table (st.c) to see how much memory was released, doing

  theHash = some_method(*args)
  GC.start
  theHash = nil
  GC.start     # and now take a look at the last output lines
 
-- 
 _           _                             
| |__   __ _| |_ ___ _ __ ___   __ _ _ __  
| '_ \ / _` | __/ __| '_ ` _ \ / _` | '_ \ 
| |_) | (_| | |_\__ \ | | | | | (_| | | | |
|_.__/ \__,_|\__|___/_| |_| |_|\__,_|_| |_|
	Running Debian GNU/Linux Sid (unstable)
batsman dot geo at yahoo dot com

* JHM wonders what Joey did to earn "I'd just like to say, for the record,
  that Joey rules."
	-- Seen on #Debian