You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@httpd.apache.org by Igor Tatarinov <ta...@prairie.NoDak.edu> on 1998/01/06 05:54:36 UTC

memory leak when adding a new module, please help!

Hi!

I got a very weird problem when trying to add my caching module to Apache.
For some reason, Apache doesn't want to release memory anymore.

Here is what I have:

- I didn't change anything in Apache itself
- I didn't overload any methods but init/config and the handler 
- I never allocate anything after init

- when my module always DECLINEs requests, everything works fine (Apache
frees memory)

- when I run my module separately (I have a small http server for that), my
small server doesn't eat memory

- when I enable my module in Apache, the httpd processes start growing
as if they never clean any pools (like if I had a single unlimited
keepalive connection).

I feel like I am lost and have no idea what could cause this problem.

I don't have to call any cleanup functions from my module, do I?

I would appreciate any suggestions, please help!
igor

Re: memory leak when adding a new module, please help!

Posted by Igor Tatarinov <ta...@prairie.NoDak.edu>.
Thanks for trying to help me out, Dean!

Actually I've finally realized that there is no memory leak in my 
module. What happens is: the child inherits the cache (an mmapped 
segment) but the cache pages are not reflected in the child process 
resident size till the child starts referencing those pages. At this
point it looks like the child starts bloating but in fact it never
grows beyond its normal size + cache size.

My main problem now is that adding my cache module somehow increases
the number of pages that have to be read from disk :( I still don't 
understand why this happens. I believe I am doing something wrong and
hope to find it out soon.

BTW, Sun's Web server (don't know if anybody uses it, at least Sun 
doesn't) uses a file cache (they mention it in their manual). I also
saw some references to a file cache in MS IIS and Netscape ES. I
also remember that folks at ORA who do WebSite said they don't use it
since it requires a lot of memory. So, it's gotta be useful if I 
finally make things work right.

igor

Dean Gaudet wrote:
> 
> It sounds like the leak is probably caused by your module.  You do have to
> make sure that all memory you allocate is in the appropriate pool (r->pool
> is almost always the right pool).  Additionally if you're doing anything
> that allocates other resources (such as mmap()) you have to register
> cleanups for them yourself... a lot of things already have generic
> cleanups you can use (fds, FILE *s, DIR *s, regexes, mmap).
> 
> Dean
> 
> On Mon, 5 Jan 1998, Igor Tatarinov wrote:
> 
> > Hi!
> >
> > I got a very weird problem when trying to add my caching module to Apache.
> > For some reason, Apache doesn't want to release memory anymore.
> >
> > Here is what I have:
> >
> > - I didn't change anything in Apache itself
> > - I didn't overload any methods but init/config and the handler
> > - I never allocate anything after init
> >
> > - when my module always DECLINEs requests, everything works fine (Apache
> > frees memory)
> >
> > - when I run my module separately (I have a small http server for that), my
> > small server doesn't eat memory
> >
> > - when I enable my module in Apache, the httpd processes start growing
> > as if they never clean any pools (like if I had a single unlimited
> > keepalive connection).
> >
> > I feel like I am lost and have no idea what could cause this problem.
> >
> > I don't have to call any cleanup functions from my module, do I?
> >
> > I would appreciate any suggestions, please help!
> > igor
> >

Re: memory leak when adding a new module, please help!

Posted by Dean Gaudet <dg...@arctic.org>.
It sounds like the leak is probably caused by your module.  You do have to
make sure that all memory you allocate is in the appropriate pool (r->pool
is almost always the right pool).  Additionally if you're doing anything
that allocates other resources (such as mmap()) you have to register
cleanups for them yourself... a lot of things already have generic
cleanups you can use (fds, FILE *s, DIR *s, regexes, mmap).

Dean

On Mon, 5 Jan 1998, Igor Tatarinov wrote:

> Hi!
> 
> I got a very weird problem when trying to add my caching module to Apache.
> For some reason, Apache doesn't want to release memory anymore.
> 
> Here is what I have:
> 
> - I didn't change anything in Apache itself
> - I didn't overload any methods but init/config and the handler 
> - I never allocate anything after init
> 
> - when my module always DECLINEs requests, everything works fine (Apache
> frees memory)
> 
> - when I run my module separately (I have a small http server for that), my
> small server doesn't eat memory
> 
> - when I enable my module in Apache, the httpd processes start growing
> as if they never clean any pools (like if I had a single unlimited
> keepalive connection).
> 
> I feel like I am lost and have no idea what could cause this problem.
> 
> I don't have to call any cleanup functions from my module, do I?
> 
> I would appreciate any suggestions, please help!
> igor
>