There seems to be a memory problem when substituing something on very long lines (several hundreds KB). this problem is different from bug 44948 (I applied this patch).

When using something like "Substitute s/string1/string2/" on a 300 KB line with 30 times "string1" on the line, there are 2 problems:

1. It uses a huge amount of memory, as - I think - it reallocates a new buffer (300 KB) before each substitute without freeing the previous one

2. The memory is not freeed at the end of the HTTP request.
Maybe is it due to Keep-alive?

If using the "q" switch to not flatten the buckets, it uses almost no memory. Btw, it correctly handles more 60 substitutions on the same line (some shorter, some longer) without the q flag !?! When exactly is this flag needed?

In macro SEDSCAT, we have
        s2 = apr_pstrmemdup(pool, buff, blen);
        s1 = apr_pstrcat(pool, s1, s2, NULL);
Shouldn't we free the previous s1 buffer?

Anyway, I do not understand why the memory is not released, as the pool is supposed to be destroyed.



Reply via email to