Hi --

On Wed, 10 Sep 2003, David Heinemeier Hansson wrote:

> > I don't think so - I think all the modules are loaded when Apache is
> > started, and each child process will have everything in the parent
> > process.  In fact, when I put a LoadModule directive inside a
> > VirtualHost section, apachectl configtest reported an error.
>
> It didn't have anything to do with IfModules or even Apache. I had a
> static constructor method as follows:
>
> def self.run
> 	@request = CGI.new
> 	self.new(@request, @request.session(Session_parameters))
> end
>
> Can you spot the instance variable reference? That caused a massive
> memory leak of a couple of hundred kb on each run.
>
> I wonder why Ruby didn't alert me to the presence of a instance
> reference in a static context? Java does that.

Because the Class object in whose context you're coding is, itself, an
instance (of Class).  So there's nothing to warn about; any object can
have instance variables, including Class objects.  What you've done is
to create an instance variable for your Class object.

This is actually a very handy technique; it's the best way to preserve
state on a true per-class basis.  (Class variables don't do that
because they're shared through inheritance.)

If you search on ruby-talk.org or Google groups for "class variables",
"class instance variables", and related things, you'll find a lot of
threads on all the permutations of this.


David

-- 
David Alan Black
home: dblack / superlink.net
work: blackdav / shu.edu
Web:  http://pirate.shu.edu/~blackdav