You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@apr.apache.org by Christopher Schultz <ch...@christopherschultz.net> on 2014/07/17 16:32:06 UTC

Possible memory leak involved in ap_rflush and friends?

All,

A user recently reported a problem with mod_jk leaking memory 8k at a
time when a certain option was enabled in the mod_jk configuration. He
included a "debugdiag" (some kinda Windows thing) trace of where memory
was being allocated and the trace goes from mod_jk into httpd/apr.

The code in mod_jk is pretty straightforward in the ws_flush function:

static void JK_METHOD ws_flush(jk_ws_service_t *s)
{
#if ! (defined(AS400) && !defined(AS400_UTF8))
    if (s && s->ws_private) {
        apache_private_data_t *p = s->ws_private;
        ap_rflush(p->r);
    }
#endif
}

apache_private_data_t->r is (somewhat obviously) a request_rec pointer.

Could someone take a look and see if anything looks fishy, either in the
way we're using this, or possibly if httpd/apr might be the cause? The
version or APR in question is 1.5.0.

https://issues.apache.org/bugzilla/show_bug.cgi?id=56733

Thanks,
-chris


Re: Possible memory leak involved in ap_rflush and friends?

Posted by Joe Orton <jo...@redhat.com>.
On Thu, Jul 17, 2014 at 09:51:55PM +0200, Ruediger Pluem wrote:
> ap_rflush creates a new brigade each time from the r->pool. So if you call it often this can sum up.
> In this case you better do the code of ap_rflush in your code and reuse the brigade instead of creating it again
> each time.

That is fixed in 2.4 tho, the non-constant-memory behaviour of ap_rflush 
(and many other places) is 2.2 specific.


Re: Possible memory leak involved in ap_rflush and friends?

Posted by Ruediger Pluem <rp...@apache.org>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA512



Christopher Schultz wrote:
> All,
> 
> A user recently reported a problem with mod_jk leaking memory 8k at a time when a certain option was enabled in the
> mod_jk configuration. He included a "debugdiag" (some kinda Windows thing) trace of where memory was being
> allocated and the trace goes from mod_jk into httpd/apr.
> 
> The code in mod_jk is pretty straightforward in the ws_flush function:
> 
> static void JK_METHOD ws_flush(jk_ws_service_t *s) { #if ! (defined(AS400) && !defined(AS400_UTF8)) if (s &&
> s->ws_private) { apache_private_data_t *p = s->ws_private; ap_rflush(p->r);

ap_rflush creates a new brigade each time from the r->pool. So if you call it often this can sum up.
In this case you better do the code of ap_rflush in your code and reuse the brigade instead of creating it again
each time.

Regards

RĂ¼diger
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.14 (GNU/Linux)
Comment: Using GnuPG with SeaMonkey - http://www.enigmail.net/

iQIcBAEBCgAGBQJTyClbAAoJEObVvtFRhboc9VQP/jhlDMFQh6TXw8Yb+MvyGlgU
KScUQnpTOGqq4aV3SCb+FZT7+AjKU92JmM++CTVEGeZ5LD75vvP5H/1otsQYsTqe
cS45q7f1HGB+6hsvnisvreAOS5lfD5RNOcEQiDjWIO4Wn3LUNn7p0aNBoPPVG2/N
7UfUvlZzoprseEdaXDVZBjcYWPeA7x+h51nrYr0wbts1PUO6tZ6oYkakKilgaYSi
s3J3RByKksK1KXyrB9keKuGqyJU0XICy3Htm6EhKXdCUwjWEYzQTm5gQBfwBR1wI
nG5tXG1FKVsSsQuNTLCwswWvIC0Y0esy+QEia+dXtrZhhn9+DYN2nFnsLHSRO3Sd
V+n1XYJD5jVVrpOTa6fdvXaNpONv/F10h+KsFH7XvaI8JAL3UbpTZGMNHDbDZHgB
qzn7+RNn9ye7BZ7UrSeWneLlr4clPCDJIlFy7aCM7RbkTE4EWDRGdqLSJ9SL8JwL
IXD9yIjwrxt+lPAPRur4wF5pxBtw2Tvaffd2a/7N61LORoIbGL7QvRZn7kExbhxM
ylMl/+oY1o1P+zrd8W4GB+bySN4gweNH8sD99pXfUHc2feONOuX4kign162Dgq3M
B3BHEVc2thKAGFevRo4HfrUIMjX4Oj9ynuiiwIqRJETHtYksggtmI8KEiV78XrL8
VnOClYGTay+mBjRMrKvc
=J81i
-----END PGP SIGNATURE-----