Changeset 128127 in webkit


Ignore:
Timestamp:
Sep 10, 2012 4:23:36 PM (12 years ago)
Author:
abarth@webkit.org
Message:

[V8] V8PerIsolateData::m_toStringTemplate leaks memory
https://bugs.webkit.org/show_bug.cgi?id=96322

Patch by Adam Barth <abarth@chromium.org> on 2012-09-10
Reviewed by Kentaro Hara.

We never call Dispose to balance the call to v8::Persistent::New. This
patch uses ScopedPersistent to call Dispose automatically.

  • bindings/v8/V8PerIsolateData.cpp:

(WebCore::V8PerIsolateData::toStringTemplate):

  • I've changed this function to return a new local handle in case anyone is trying to hold on to these handles during shutdown.
  • bindings/v8/V8PerIsolateData.h:

(V8PerIsolateData):

Location:
trunk/Source/WebCore
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r128126 r128127  
     12012-09-10  Adam Barth  <abarth@chromium.org>
     2
     3        [V8] V8PerIsolateData::m_toStringTemplate leaks memory
     4        https://bugs.webkit.org/show_bug.cgi?id=96322
     5
     6        Reviewed by Kentaro Hara.
     7
     8        We never call Dispose to balance the call to v8::Persistent::New. This
     9        patch uses ScopedPersistent to call Dispose automatically.
     10
     11        * bindings/v8/V8PerIsolateData.cpp:
     12        (WebCore::V8PerIsolateData::toStringTemplate):
     13            - I've changed this function to return a new local handle in case
     14              anyone is trying to hold on to these handles during shutdown.
     15        * bindings/v8/V8PerIsolateData.h:
     16        (V8PerIsolateData):
     17
    1182012-09-10  Adam Barth  <abarth@chromium.org>
    219
  • trunk/Source/WebCore/bindings/v8/V8PerIsolateData.cpp

    r128125 r128127  
    7575}
    7676
     77v8::Handle<v8::FunctionTemplate> V8PerIsolateData::toStringTemplate()
     78{
     79    if (m_toStringTemplate.isEmpty())
     80        m_toStringTemplate.set(v8::FunctionTemplate::New(constructorOfToString));
     81    return v8::Local<v8::FunctionTemplate>::New(m_toStringTemplate.get());
     82}
     83
    7784void V8PerIsolateData::reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
    7885{
  • trunk/Source/WebCore/bindings/v8/V8PerIsolateData.h

    r128125 r128127  
    7272    TemplateMap& templateMap() { return m_templates; }
    7373
    74     v8::Persistent<v8::FunctionTemplate>& toStringTemplate()
    75     {
    76         if (m_toStringTemplate.IsEmpty())
    77             m_toStringTemplate = v8::Persistent<v8::FunctionTemplate>::New(v8::FunctionTemplate::New(constructorOfToString));
    78         return m_toStringTemplate;
    79     }
    80 
     74    v8::Handle<v8::FunctionTemplate> toStringTemplate();
    8175    v8::Persistent<v8::FunctionTemplate>& lazyEventListenerToStringTemplate()
    8276    {
     
    144138    TemplateMap m_rawTemplates;
    145139    TemplateMap m_templates;
    146     v8::Persistent<v8::FunctionTemplate> m_toStringTemplate;
     140    ScopedPersistent<v8::FunctionTemplate> m_toStringTemplate;
    147141    v8::Persistent<v8::FunctionTemplate> m_lazyEventListenerToStringTemplate;
    148142    OwnPtr<StringCache> m_stringCache;
Note: See TracChangeset for help on using the changeset viewer.