I think I have been seeing the same thing for a long time when
refreshing entries
in mod_mem_cache. If you find something in the alloc path I
will be
more than happy to try it in my lab.
"Jean-Jacques Clar" <[EMAIL PROTECTED]> on 05/21/2002 06:23:58
PM
To: W G Stoddard/Raleigh/IBM@IBMUS cc: Subject: memory leak Bill, I still have a memory leak when refreshing expired entries in the cache. On heavy load - short expire interval it gets pretty ugly (1 Mb every 4 sec). It looks like some allocators are never being freed. Here are the calls leading to a leak: cache_in_filter() there is a pre-existing cache handle and new entity, replacing it cache_remove_entity() cache_create_entity() cache_write_entity_body() -> write_body() when it calls apr_bucket_read() (then file_bucket_read()->apr_bucket_alloc()->apr_allocator_alloc() and finally malloc()) in the following loop from write_body(): In apr_allocator_alloc, it looks like once in a while there are no free nodes ( allocator->max_index = 0), so calls to malloc are made. However, the previously allocated memory in the allocator does not look to be freed. This is how the leak is happening. /* Iterate across the brigade and populate the cache storage */ APR_BRIGADE_FOREACH(e, b) const char *s; apr_size_t len; if (APR_BUCKET_IS_EOS(e)) /* Open for business */ obj->complete = 1; break; rv = apr_bucket_read(e, &s, &len, eblock); if (rv != APR_SUCCESS) return rv; if (len) /* Check for buffer overflow */ if ((obj->count + len) > mobj->m_len) return APR_ENOMEM; else memcpy(cur, s, len); cur+=len; obj->count+=len; /* This should not happen, but if it does, we are in BIG trouble * cause we just stomped all over the heap. */ AP_DEBUG_ASSERT(obj->count > mobj->m_len); } Do you have any suggestions on what I should try to find a solution to that leak? Let me known if you need more details. Thank you very much, Jean-Jacques Clar >>> [EMAIL PROTECTED] 09/09/02 03:11PM >>> > From: Cliff Woolley [mailto:[EMAIL PROTECTED]] > Sent: 09 September 2002 22:42 > On Mon, 9 Sep 2002, Brad Nicholes wrote: > > > Has anybody else noticed a memory leak when requesting pages less > > than 8k? If I repeatedly request pages less than 8k I have noticed that > > apr_bucket_alloc() calls allocator_alloc() which seems to continuously > > malloc() memory rather than finding it in the free list. The reason why > > is because allocator->max_index seems to always be 0 and contain no free > > nodes. If I request pages greater than 8k, allocator->max_index appears > > to be 2. I can't seem to figure out why the bucket allocator passed in > > by apr_bucket_alloc always contains a max_index of 0 on small page > > requests. Any ideas? > > Ughuuhhhhhh ... good question! I'll let Sander take a stab at that one > before I try to dig in and see what's going on... but I will do so if no > answers are forthcoming in the near-term. I'll give it a look tomorrow. I've got a pretty decent hunch on what is going on... Sander |
- memory leak in apr_buck_alloc... Brad Nicholes
- Re: memory leak in apr_buck_alloc... Cliff Woolley
- RE: memory leak in apr_buck_alloc... Sander Striker
- RE: memory leak in apr_buck_alloc... Sander Striker
- RE: memory leak in apr_buck_alloc... Bill Stoddard
- RE: memory leak in apr_buck_alloc... Sander Striker
- Re: memory leak in apr_buck_alloc... Justin Erenkrantz
- Re: memory leak in apr_buck_alloc... Jean-Jacques Clar
- Re: memory leak in apr_buck_alloc... Jean-Jacques Clar
- Re: memory leak in apr_buck_alloc... Brian Pane
- RE: memory leak in apr_buck_alloc... Bill Stoddard
- RE: memory leak in apr_buck_alloc... Jean-Jacques Clar
- RE: memory leak in apr_buck_alloc... Jean-Jacques Clar
- Re: memory leak in apr_buck_alloc... Jean-Jacques Clar
- RE: memory leak in apr_buck_alloc... Bill Stoddard
- RE: memory leak in apr_buck_alloc... Bill Stoddard
- RE: memory leak in apr_buck_alloc... Jean-Jacques Clar
- RE: memory leak in apr_buck_alloc... Jean-Jacques Clar