diff options
author | erikkay@google.com <erikkay@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-08-08 21:49:40 +0000 |
---|---|---|
committer | erikkay@google.com <erikkay@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-08-08 21:49:40 +0000 |
commit | 832a1f65dc87dc2662966d53285aa597e68435a8 (patch) | |
tree | 4c9c9b217d5359783c432956f9d3364c71615cff /webkit/port | |
parent | 41229ef580d93558be14c08924322d4f414e9703 (diff) | |
download | chromium_src-832a1f65dc87dc2662966d53285aa597e68435a8.zip chromium_src-832a1f65dc87dc2662966d53285aa597e68435a8.tar.gz chromium_src-832a1f65dc87dc2662966d53285aa597e68435a8.tar.bz2 |
Limit the number of console messages we keep in memory so a poorly behaving script does not cause unbounded memory growth.
This should likely be fixed upstream as well, but I think we should do it locally for beta.
BUG=1313462
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@595 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/port')
-rw-r--r-- | webkit/port/page/inspector/InspectorController.cpp | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/webkit/port/page/inspector/InspectorController.cpp b/webkit/port/page/inspector/InspectorController.cpp index 3c1a551..3b90744 100644 --- a/webkit/port/page/inspector/InspectorController.cpp +++ b/webkit/port/page/inspector/InspectorController.cpp @@ -101,6 +101,9 @@ using namespace std; namespace WebCore { +// Maximum size of the console message cache. +static const int MAX_CONSOLE_MESSAGES = 250; + namespace bug1228513 { // TODO(ericroman): Temporary hacks to help diagnose http://b/1228513 @@ -1377,6 +1380,18 @@ void InspectorController::addConsoleMessage(ConsoleMessage* consoleMessage) ASSERT(enabled()); ASSERT_ARG(consoleMessage, consoleMessage); + // Limit the number of console messages we keep in memory so a poorly + // behaving script doesn't cause unbounded memory growth. We remove the + // oldest messages so that the most recent errors are preserved. + // TODO(erikkay): this is not very efficient since Vector has to do a copy + // when you remove from anywhere other than the end. Unfortunately, WTF + // doesn't appear to have a double-ended list we could use instead. The + // extra CPU cost is definitely better than the memory cost. + if (m_consoleMessages.size() >= MAX_CONSOLE_MESSAGES) { + ConsoleMessage* msg = m_consoleMessages[0]; + m_consoleMessages.remove(0); + delete msg; + } m_consoleMessages.append(consoleMessage); if (windowVisible()) |