Quoting Mark Rowe <[EMAIL PROTECTED]>:
> Check out this further pool test,
>
>
> Using apache 2.0.48
>
> I defined tenbyte_string as the
> constant string "0123456789"
> which is 10 bytes long.
This would probably be 11 bytes, plus maybe a few extra for alignment. Not a big
difference probably, nevertheless...
> char *s = "";
[...]
> apr_pool_create_ex(&subp1, p, fun, NULL);
> apr_pool_create_ex(&subp2, p, fun, NULL);
> for (i = 0; i < 10000; i++) {
> apr_pool_clear(subp1);
> s = apr_pstrcat(subp1, s, tenbyte_string, NULL);
> apr_pool_clear(subp2);
> s = apr_pstrdup(subp2, s);
The the above duplicates s, so now we have 220,000 raw storage requirement,
given there are two pools in play. At least I think.
> }
> apr_pool_destroy(subp1);
> apr_pool_destroy(subp2);
Isn't there some sort of algorithm in play that says:
- allocate contiguousregion of memory
- fit stuff into that region
- if it doesn't fit, allocate twice the size (or something)
- fit stuff into that other region if first doesn't have enough space
- and so on
This might explain why the memory usage is soaring as you keep increasing the
string size.
I'm not sure why memory isn't returned to the system on apr_pool_destroy().
Maybe it simply gets pasted to the parent pool in case that one needs more
memory in the future?
--
Bojan