ClosestStorm / v8cgi

Automatically exported from code.google.com/p/v8cgi
BSD 3-Clause "New" or "Revised" License
0 stars 1 forks source link

massive memory leak #47

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Hi, 

Yesterday I tried to check performance of the server with Apache Benchmark.
I made 1000 requests and monit restarted apache because of 200MB memory
limit it reached.

I looked through code and found one place where memory allocated with new
char[] but freed with free(). it's in mod_v8cgi.cc (mod_v8cgi_handler
function). I've fixed this but module still eats memory. 

The bug should be somewhere else, but it's hard for me to find it because I
don't have normal dev environment yet.

Original issue reported on code.google.com by neoco...@gmail.com on 10 Dec 2009 at 2:56

GoogleCodeExporter commented 9 years ago

Original comment by ondrej.zara on 10 Dec 2009 at 9:01

GoogleCodeExporter commented 9 years ago
Where exactly in mod_v8cgi_handler do you see the leak? The only new'ed 
structure is
the char ** envp and this is freed in the end of functions...

Original comment by ondrej.zara on 10 Dec 2009 at 9:06

GoogleCodeExporter commented 9 years ago
Yes they freed with free() function but should be freed with delete[] as they 
are
created with new[]. I don't really think that this could cause the leak bu as 
far as
I saw on the net everyone recommend to use standard malloc()/free() or 
new[]/delete[] pairs. 

I ran Valgrind memory leak detector and it showed only these problems. 
Everything
else is a possible leaks because of using apr pool.(two logs are attached. 
before
"delete[]" patch and after).

Ondrej, where can I download the latest libv8 source to see if it has this 
problem?
Now I'm using source provided with v8cgi 0.7.5.

Oh, here is the link to Valgrind if it will be helpful - http://valgrind.org/

Original comment by neoco...@gmail.com on 10 Dec 2009 at 9:21

Attachments:

GoogleCodeExporter commented 9 years ago
Okay, you are right. Can you please send me the patch you have so far?

As for the V8, please see http://code.google.com/p/v8/wiki/Source?tm=4 .

Original comment by ondrej.zara on 10 Dec 2009 at 9:30

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
Sure

Original comment by neoco...@gmail.com on 10 Dec 2009 at 9:42

Attachments:

GoogleCodeExporter commented 9 years ago
Okay, your fix added as r693. I will try to investigate more leaks.

Original comment by ondrej.zara on 11 Dec 2009 at 7:05

GoogleCodeExporter commented 9 years ago
Revision 738 fixes all (two) leaks detectable by valgrind in v8cgi code. 

Original comment by ondrej.zara on 22 Jan 2010 at 2:33