Changeset 118357 in webkit


Ignore:
Timestamp:
May 24, 2012 6:01:53 AM (12 years ago)
Author:
yurys@chromium.org
Message:

Web Inspector: add a command to InspectorMemoryAgent for getting process memory break down
https://bugs.webkit.org/show_bug.cgi?id=87263

Reviewed by Pavel Feldman.

Source/WebCore:

Introduced new protocol command Memory.getProcessMemoryDistribution which returns
memory distribution for the inspected process. Currently only JS allocated and used
heap size is included.

  • inspector/Inspector.json:
  • inspector/InspectorMemoryAgent.cpp:

(WebCore::jsHeapInfo):
(WebCore):
(WebCore::InspectorMemoryAgent::getProcessMemoryDistribution):

  • inspector/InspectorMemoryAgent.h:

(InspectorMemoryAgent):

  • platform/chromium/PlatformSupport.h:

(PlatformSupport):

Source/WebKit/chromium:

Added an API for retrieving render process private and shared memory in bytes.

  • public/platform/WebKitPlatformSupport.h:

(WebKitPlatformSupport):
(WebKit::WebKitPlatformSupport::getProcessMemorySize):

  • src/PlatformSupport.cpp:

(WebCore::PlatformSupport::getProcessMemorySize):
(WebCore):

Location:
trunk/Source
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r118353 r118357  
     12012-05-23  Yury Semikhatsky  <yurys@chromium.org>
     2
     3        Web Inspector: add a command to InspectorMemoryAgent for getting process memory break down
     4        https://bugs.webkit.org/show_bug.cgi?id=87263
     5
     6        Reviewed by Pavel Feldman.
     7
     8        Introduced new protocol command Memory.getProcessMemoryDistribution which returns
     9        memory distribution for the inspected process. Currently only JS allocated and used
     10        heap size is included.
     11
     12        * inspector/Inspector.json:
     13        * inspector/InspectorMemoryAgent.cpp:
     14        (WebCore::jsHeapInfo):
     15        (WebCore):
     16        (WebCore::InspectorMemoryAgent::getProcessMemoryDistribution):
     17        * inspector/InspectorMemoryAgent.h:
     18        (InspectorMemoryAgent):
     19        * platform/chromium/PlatformSupport.h:
     20        (PlatformSupport):
     21
    1222012-05-24  Nikolas Zimmermann  <nzimmermann@rim.com>
    223
  • trunk/Source/WebCore/inspector/Inspector.json

    r118349 r118357  
    8888                    { "name": "listenerCount", "type": "array", "items": { "$ref": "ListenerCount" }}
    8989                ]
     90            },
     91            {
     92                "id": "MemoryBlock",
     93                "type": "object",
     94                "properties": [
     95                    { "name": "size", "type": "integer", "optional":true, "description": "Size of the block in bytes if available" },
     96                    { "name": "name", "type": "string", "description": "Unique name used to identify the component that allocated this block" },
     97                    { "name": "children", "type": "array", "optional": true, "items": { "$ref": "MemoryBlock" }}
     98                ]
    9099            }
    91100        ],
     
    96105                    { "name": "domGroups", "type": "array", "items": { "$ref": "DOMGroup" }},
    97106                    { "name": "strings", "$ref": "StringStatistics" }
     107                ]
     108            },
     109            {
     110                "name": "getProcessMemoryDistribution",
     111                "returns": [
     112                    { "name": "distribution", "$ref": "MemoryBlock", "description": "An object describing all memory allocated by the process"}
    98113                ]
    99114            }
  • trunk/Source/WebCore/inspector/InspectorMemoryAgent.cpp

    r113438 r118357  
    4646#include "Node.h"
    4747#include "Page.h"
     48#if PLATFORM(CHROMIUM)
     49#include "PlatformSupport.h"
     50#endif
     51#include "ScriptGCEvent.h"
    4852#include "ScriptProfiler.h"
    4953#include "StyledElement.h"
     
    5357using WebCore::TypeBuilder::Memory::DOMGroup;
    5458using WebCore::TypeBuilder::Memory::ListenerCount;
     59using WebCore::TypeBuilder::Memory::MemoryBlock;
    5560using WebCore::TypeBuilder::Memory::NodeCount;
    5661using WebCore::TypeBuilder::Memory::StringStatistics;
    5762
    5863namespace WebCore {
     64
     65namespace MemoryBlockName {
     66static const char totalJsHeap[] = "TotalJSHeap";
     67static const char processPrivateMemory[] = "ProcessPrivateMemory";
     68static const char usedJsHeap[] = "UsedJSHeap";
     69}
    5970
    6071namespace {
     
    308319}
    309320
     321static PassRefPtr<MemoryBlock> jsHeapInfo()
     322{
     323    size_t usedJSHeapSize;
     324    size_t totalJSHeapSize;
     325    size_t jsHeapSizeLimit;
     326    ScriptGCEvent::getHeapSize(usedJSHeapSize, totalJSHeapSize, jsHeapSizeLimit);
     327
     328    RefPtr<MemoryBlock> totalJsHeap = MemoryBlock::create().setName(MemoryBlockName::totalJsHeap);
     329    totalJsHeap->setSize(totalJSHeapSize);
     330
     331    RefPtr<TypeBuilder::Array<MemoryBlock> > children = TypeBuilder::Array<MemoryBlock>::create();
     332    RefPtr<MemoryBlock> usedJsHeap = MemoryBlock::create().setName(MemoryBlockName::usedJsHeap);
     333    usedJsHeap->setSize(usedJSHeapSize);
     334    children->addItem(usedJsHeap);
     335
     336    totalJsHeap->setChildren(children);
     337    return totalJsHeap.release();
     338}
     339
     340void InspectorMemoryAgent::getProcessMemoryDistribution(ErrorString*, RefPtr<MemoryBlock>& processMemory)
     341{
     342    size_t privateBytes = 0;
     343#if PLATFORM(CHROMIUM)
     344    size_t sharedBytes = 0;
     345    PlatformSupport::getProcessMemorySize(&privateBytes, &sharedBytes);
     346#endif
     347    processMemory = MemoryBlock::create().setName(MemoryBlockName::processPrivateMemory);
     348    processMemory->setSize(privateBytes);
     349
     350    RefPtr<TypeBuilder::Array<MemoryBlock> > children = TypeBuilder::Array<MemoryBlock>::create();
     351    children->addItem(jsHeapInfo());
     352    processMemory->setChildren(children);
     353}
     354
    310355InspectorMemoryAgent::InspectorMemoryAgent(InstrumentingAgents* instrumentingAgents, InspectorState* state, Page* page, InspectorDOMAgent* domAgent)
    311356    : InspectorBaseAgent<InspectorMemoryAgent>("Memory", instrumentingAgents, state)
  • trunk/Source/WebCore/inspector/InspectorMemoryAgent.h

    r113157 r118357  
    5757        return adoptPtr(new InspectorMemoryAgent(instrumentingAgents, state, page, domAgent));
    5858    }
     59    virtual ~InspectorMemoryAgent();
    5960
    60     void getDOMNodeCount(ErrorString*, RefPtr<TypeBuilder::Array<TypeBuilder::Memory::DOMGroup> >& domGroups, RefPtr<TypeBuilder::Memory::StringStatistics>& strings);
     61    virtual void getDOMNodeCount(ErrorString*, RefPtr<TypeBuilder::Array<TypeBuilder::Memory::DOMGroup> >& domGroups, RefPtr<TypeBuilder::Memory::StringStatistics>& strings);
     62    virtual void getProcessMemoryDistribution(ErrorString*, RefPtr<TypeBuilder::Memory::MemoryBlock>& processMemory);
    6163
    62     ~InspectorMemoryAgent();
    6364
    6465private:
  • trunk/Source/WebCore/inspector/InspectorTimelineAgent.cpp

    r118351 r118357  
    5757}
    5858
    59 // Must be kept in sync with TimelineAgent.js
     59// Must be kept in sync with WebInspector.TimelineModel.RecordType in TimelineModel.js
    6060namespace TimelineRecordType {
    6161static const char EventDispatch[] = "EventDispatch";
  • trunk/Source/WebCore/platform/chromium/PlatformSupport.h

    r118110 r118357  
    214214    static void setSharedTimerFireInterval(double);
    215215
     216    // Returns private and shared usage, in bytes. Private bytes is the amount of
     217    // memory currently allocated to this process that cannot be shared. Returns
     218    // false on platform specific error conditions.
     219    static bool getProcessMemorySize(size_t* privateBytes, size_t* sharedBytes);
    216220    // Theming ------------------------------------------------------------
    217221#if OS(WINDOWS)
  • trunk/Source/WebKit/chromium/ChangeLog

    r118352 r118357  
     12012-05-23  Yury Semikhatsky  <yurys@chromium.org>
     2
     3        Web Inspector: add a command to InspectorMemoryAgent for getting process memory break down
     4        https://bugs.webkit.org/show_bug.cgi?id=87263
     5
     6        Reviewed by Pavel Feldman.
     7
     8        Added an API for retrieving render process private and shared memory in bytes.
     9
     10        * public/platform/WebKitPlatformSupport.h:
     11        (WebKitPlatformSupport):
     12        (WebKit::WebKitPlatformSupport::getProcessMemorySize):
     13        * src/PlatformSupport.cpp:
     14        (WebCore::PlatformSupport::getProcessMemorySize):
     15        (WebCore):
     16
    1172012-05-24  Hironori Bono  <hbono@chromium.org>
    218
  • trunk/Source/WebKit/chromium/public/platform/WebKitPlatformSupport.h

    r118252 r118357  
    129129    virtual WebSharedWorkerRepository* sharedWorkerRepository() { return 0; }
    130130
     131    // Returns private and shared usage, in bytes. Private bytes is the amount of
     132    // memory currently allocated to this process that cannot be shared. Returns
     133    // false on platform specific error conditions.
     134    virtual bool getProcessMemorySize(size_t* privateBytes, size_t* sharedBytes) { return false; }
    131135
    132136protected:
  • trunk/Source/WebKit/chromium/src/PlatformSupport.cpp

    r118237 r118357  
    838838}
    839839
     840bool PlatformSupport::getProcessMemorySize(size_t* privateBytes, size_t* sharedBytes)
     841{
     842    return webKitPlatformSupport()->getProcessMemorySize(privateBytes, sharedBytes);
     843}
     844
    840845int PlatformSupport::screenHorizontalDPI(Widget* widget)
    841846{
Note: See TracChangeset for help on using the changeset viewer.