- From: Bertrand LUPART <bertrand.lupart AT linkeo.com>
- To: caudium-devel AT caudium.net
- Subject: Auditing caudium.c : f_parse_query_string()
- Date: Mon, 30 Jan 2006 21:42:46 +0100
Hello,
Let's start a community-driven effort for chasing possible memory
leaks in caudium.c
Since i don't know how to use the hilfe module in Caudium, let's try
to simulate that with top of the art of our technologies: Pike 7.6.66
and Caudium 1.5.1-20010130:
----8<----8<----8<----8<----
$ pike -M /sw/lib/caudium1.5/etc/modules/ -I /sw/lib/caudium1.5/etc/
include/ -I /sw/lib/caudium1.5/base_server/ -M /sw/lib/caudium1.5/lib/
7.6.66/
Pike v7.6 release 66 running Hilfe v3.5 (Incremental Pike Frontend)
> indices(_Caudium);
(1) Result: ({ /* 24 elements */
"parse_query_string",
"http_encode_string",
"http_encode_cookie",
"_make_tag_attributes",
"html_encode_mapping",
"xml_encode_mapping",
"program_object_memory_usage",
"ParseHTTP",
"is_modified",
"parse_date",
"strftime",
"getdate",
"parse_entities",
"http_decode_url",
"http_encode_url",
"http_date",
"cern_http_date",
"http_decode",
"http_encode",
"extension",
"get_port",
"parse_prestates",
"parse_headers",
"get_address"
})
---->8---->8---->8---->8----
Let's try the first one: parse_query_string()
For testing that, I cooked a Test.pmod which builds random query
strings.
Ready?
----8<----8<----8<----8<----
$ pike -M /sw/lib/caudium1.5/etc/modules/ -I /sw/lib/caudium1.5/etc/
include/ -I /sw/lib/caudium1.5/base_server/ -M /sw/lib/caudium1.5/lib/
7.6.66/ -M /Users/bertrand/Code/Caudium/testing/
Pike v7.6 release 66 running Hilfe v3.5 (Incremental Pike Frontend)
> dump memory
Num Bytes
array 354 43236 (42.2 kb)
callable 224 8152 (8.0 kb)
callback 4 4128 (4.0 kb)
frame 7 16300 (15.9 kb)
mapping 97 91634 (89.5 kb)
multiset 36 19980 (19.5 kb)
object 95 22768 (22.2 kb)
program 146 171360 (167.3 kb)
string 4586 178997 (174.8 kb)
---->8---->8---->8---->8----
Let's build 10000 random queries of 100 variables (with a random
amount of unset variables), indices and values size set to 10
characters:
----8<----8<----8<----8<----
> array queries = Test.random_queries(10000, 100);
> dump memory
Num Bytes
array 1565 289160 (282.4 kb)
callable 234 16304 (15.9 kb)
callback 4 4128 (4.0 kb)
frame 7 16300 (15.9 kb)
mapping 564 296275 (289.3 kb)
multiset 54 28572 (27.9 kb)
object 284 60272 (58.9 kb)
program 423 517416 (505.3 kb)
string 20201 35340830 (33.7 Mb)
---->8---->8---->8---->8----
That's our base memory footprint. Now, just parse all that:
----8<----8<----8<----8<----
> foreach(queries, string query){
>> mapping variables = ([ ]);
>> multiset unset = (< >);
>> _Caudium.parse_query_string(query, variables, unset);
>> }
Ok.
> dump memory
Num Bytes
array 1569 289368 (282.6 kb)
callable 256 16304 (15.9 kb)
callback 4 4128 (4.0 kb)
frame 7 16300 (15.9 kb)
mapping 564 295339 (288.4 kb)
multiset 40 18176 (17.8 kb)
object 285 60272 (58.9 kb)
program 425 518932 (506.8 kb)
string 2019810 107488870 (102.5 Mb)
---->8---->8---->8---->8----
Call the garbage collector, just in case:
----8<----8<----8<----8<----
> gc();
(1) Result: 0
> dump memory
Num Bytes
array 1569 289344 (282.6 kb)
callable 256 16304 (15.9 kb)
callback 4 4128 (4.0 kb)
frame 7 16300 (15.9 kb)
mapping 564 295339 (288.4 kb)
multiset 40 18176 (17.8 kb)
object 285 60272 (58.9 kb)
program 425 518932 (506.8 kb)
string 2019810 107488703 (102.5 Mb)
---->8---->8---->8---->8----
Am i wrong somewhere or are we leaking strings here?
--
Bertrand LUPART
Linkeo.com |
http://www.linkeo.com
+33 1 72 71 71 84 | 17, rue de la Banque -
F75002 Paris
- Auditing caudium.c : f_parse_query_string(), Bertrand LUPART
Archive powered by MhonArc 2.6.10.