ericmckean / chromedriver

Automatically exported from code.google.com/p/chromedriver
0 stars 0 forks source link

Chromedriver memory leak in devtools_client_impl.cc #926

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Hello,

I've recently discovered a memory leak in the chrome driver source code while 
working on the automation test software being used by my company.

We have been utilizing Chromedriver as our browser driver for Selenium, and 
noticed that the Chromedriver used more and more memory,
as the testing time increased.

We decided to search for leaks within Chromedriver application. After using 
Valgrind, gdb, and Valgrind Massif Visualization tool, I have discovered that
Chromedriver is leaking at precisely devtools_client_impl.cc:242.

The ResponseInfo object that is getting created here is never being garbage 
collected.

To fix the leak I implemented a hacky solution. I had to add the following code 
to the beginning of the SendCommandInternal function in  
devtools_client_impl.cc:228:

  if( response_info_map_.size() > 200 )
  {
    response_info_map_.clear();
    next_id_ = 1;
  }

Do any of you Chromium developers know a non-hacky solution to this problem? I 
have attached the Valgrind Massif Memory Allocation chart as a proof
for the memory leak.

This hacky solution breaks the chromedriver unit tests.

I would like to submit a real fix for this problem, as my company heavily 
relies on Chromedriver for testing applications.

Original issue reported on code.google.com by alp.soyu...@willowglensystems.com on 8 Oct 2014 at 4:47

GoogleCodeExporter commented 9 years ago

Original comment by samu...@chromium.org on 10 Oct 2014 at 6:22

GoogleCodeExporter commented 9 years ago
I've been running with the following patch for about 20 hours now and 
ChromeDriver 2.11 is using about 1 GB of RAM. With the patch, it is steady at 
about 12 MB.

https://codereview.chromium.org/643003003

The problem is that we create a ResponseInfo object for every DevTools command, 
and this gets stored in response_info_map_, but never deleted. My change fixes 
this so that we delete ResponseInfo objects from the map after we get a command 
response from DevTools.

Original comment by samu...@chromium.org on 11 Oct 2014 at 1:43

GoogleCodeExporter commented 9 years ago
Issue 927 has been merged into this issue.

Original comment by samu...@chromium.org on 11 Oct 2014 at 1:44

GoogleCodeExporter commented 9 years ago
The patch that I mentioned in #2 is now landed, and will be part of 
ChromeDriver 2.12.

Original comment by samu...@chromium.org on 16 Oct 2014 at 4:17

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

Original comment by samu...@chromium.org on 27 Oct 2014 at 8:47

GoogleCodeExporter commented 9 years ago
Issue chromium:421484 has been merged into this issue.

Original comment by samu...@chromium.org on 29 Oct 2014 at 5:14

GoogleCodeExporter commented 9 years ago

Original comment by samu...@chromium.org on 21 Feb 2015 at 12:26