summaryrefslogtreecommitdiffstats
path: root/o3d/plugin/win/main_win.cc
diff options
context:
space:
mode:
authorvangelis@google.com <vangelis@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-06-25 18:57:49 +0000
committervangelis@google.com <vangelis@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-06-25 18:57:49 +0000
commit1b75d896b863c5635566e31b0e3314e94e9f4113 (patch)
tree32cefd262053fe5043d62684268ebf83ced0389b /o3d/plugin/win/main_win.cc
parentce42ccee72841c8a9ad975712c39e6ede84feb61 (diff)
downloadchromium_src-1b75d896b863c5635566e31b0e3314e94e9f4113.zip
chromium_src-1b75d896b863c5635566e31b0e3314e94e9f4113.tar.gz
chromium_src-1b75d896b863c5635566e31b0e3314e94e9f4113.tar.bz2
Call V8::Dispose() when the plugin dll is unloaded from the browser so that memory used by V8 can be properly freed. This fixes intermittend crashes in IE selenenium tests.
Review URL: http://codereview.chromium.org/146135 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@19269 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'o3d/plugin/win/main_win.cc')
-rw-r--r--o3d/plugin/win/main_win.cc16
1 files changed, 16 insertions, 0 deletions
diff --git a/o3d/plugin/win/main_win.cc b/o3d/plugin/win/main_win.cc
index 5f36f97..df70b0e 100644
--- a/o3d/plugin/win/main_win.cc
+++ b/o3d/plugin/win/main_win.cc
@@ -47,6 +47,7 @@
#include "plugin/cross/plugin_logging.h"
#include "plugin/cross/out_of_memory.h"
#include "statsreport/metrics.h"
+#include "third_party/v8/include/v8.h"
#include "breakpad/win/bluescreen_detector.h"
using glue::_o3d::PluginObject;
@@ -640,6 +641,21 @@ WindowProc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam) {
}
extern "C" {
+ BOOL WINAPI DllMain(HINSTANCE instance, DWORD reason, LPVOID reserved) {
+ if (reason == DLL_PROCESS_DETACH) {
+ // Teardown V8 when the plugin dll is unloaded.
+ // NOTE: NP_Shutdown would have been a good place for this code but
+ // unfortunately it looks like it gets called even when the dll
+ // isn't really unloaded. This is a problem since after calling
+ // V8::Dispose(), V8 cannot be initialized again.
+ bool v8_disposed = v8::V8::Dispose();
+ if (!v8_disposed)
+ DLOG(ERROR) << "Failed to release V8 resources.";
+ return true;
+ }
+ return true;
+ }
+
NPError InitializePlugin() {
if (!o3d::SetupOutOfMemoryHandler())
return NPERR_MODULE_LOAD_FAILED_ERROR;