[Ieleak-commit] SF.net SVN: ieleak: [118] trunk/sieve/src
Brought to you by:
matthiasmiller
From: <cor...@us...> - 2006-08-14 14:23:05
|
Revision: 118 Author: cordys-os Date: 2006-08-14 07:22:30 -0700 (Mon, 14 Aug 2006) ViewCVS: http://svn.sourceforge.net/ieleak/?rev=118&view=rev Log Message: ----------- - Added UI for detected Cycles. Cycles are now counted as 'Leak'. As soon a cycle is detected the properties of the leaked element will show the precise path of the cycle. - Moved 2 helper function inside the sIEveHooks.js file (code rearrange) Modified Paths: -------------- trunk/sieve/src/JSHook.cpp trunk/sieve/src/JSHook.hpp trunk/sieve/src/LeakDlg.cpp trunk/sieve/src/sIEveHooks.js Modified: trunk/sieve/src/JSHook.cpp =================================================================== --- trunk/sieve/src/JSHook.cpp 2006-08-14 09:55:51 UTC (rev 117) +++ trunk/sieve/src/JSHook.cpp 2006-08-14 14:22:30 UTC (rev 118) @@ -45,6 +45,8 @@ dispIds[i] = 1; else if (!wcscmp(names[i], L"rescanForElements")) dispIds[i] = 2; + else if (!wcscmp(names[i], L"logDetectedCycle")) + dispIds[i] = 3; else { dispIds[i] = -1; @@ -111,6 +113,26 @@ } return S_OK; } + else if ( dispId == 3 ) + { + // logDetectedCycle() takes one argument, elem + // + if (dispParams->cArgs != 1) + return DISP_E_BADPARAMCOUNT; + + if (dispParams->rgvarg[0].vt != VT_DISPATCH) + return DISP_E_BADVARTYPE; + + // Get the element, and add the element to the list. + // + MSHTML::IHTMLDOMNodePtr elem = dispParams->rgvarg[0].pdispVal; + Elem* cachedElem = getElement(elem); + if ( cachedElem ) + { + cachedElem->cycleDetected = true; + } + return S_OK; + } else return DISP_E_MEMBERNOTFOUND; } @@ -274,6 +296,22 @@ } } +Elem* JSHook::getElement(MSHTML::IHTMLDOMNodePtr elem) +{ + if ( elem ) + { + IUnknown *unkElem; + elem->QueryInterface(IID_IUnknown, (void**)&unkElem); + std::map<IUnknown*,Elem>::iterator pair = m_elements.find(unkElem); + unkElem->Release(); + + if ( pair == m_elements.end() ) return NULL; + Elem& cachedElem = pair->second; + return &cachedElem; + } + return NULL; +} + void JSHook::hookNewElement(MSHTML::IHTMLDOMNodePtr elem, MSHTML::IHTMLDocument2Ptr doc ) { if ( elem->nodeType != NODE_TEXT ) @@ -536,8 +574,8 @@ if ( showLeaks ) { - // Only show all leaks - if ( !elem.docElem->running && refCount > 1) + // Only show all leaks (And thus also the detected cycles) + if ( (!elem.docElem->running && refCount > 1) || elem.cycleDetected ) { dlg->addElement(unk, &elem, refCount - 1, false, 0, elem.leakReported ); elem.leakReported = refCount - 1; @@ -602,9 +640,9 @@ // If any references (other than the one that we hold) are outstanding, then // the element has been leaked. - // + // OR if we detected a cycle - if ( !elem.docElem->running && refCount > 1) + if ( (!elem.docElem->running && refCount > 1) || elem.cycleDetected ) { leakedItems++; } Modified: trunk/sieve/src/JSHook.hpp =================================================================== --- trunk/sieve/src/JSHook.hpp 2006-08-14 09:55:51 UTC (rev 117) +++ trunk/sieve/src/JSHook.hpp 2006-08-14 14:22:30 UTC (rev 118) @@ -20,6 +20,7 @@ this->docId = 0; this->docElem = NULL; this->documentHasLeaks = false; + this->cycleDetected = false; } int seqNr; BSTR url; @@ -31,6 +32,7 @@ int docId; Elem* docElem; BOOL documentHasLeaks; + BOOL cycleDetected; }; class __declspec(uuid("8340a7f2-413a-46dd-9f95-fbad5d455a90")) IJSHook: public IDispatch { }; @@ -45,6 +47,7 @@ class JSHook: public IJSHook, public ATL::CComObjectRoot { private: void addElement(MSHTML::IHTMLDOMNode* elem); + Elem* getElement(MSHTML::IHTMLDOMNodePtr elem); void addElementRecursively(MSHTML::IHTMLDOMNode* elem); void releaseExtraReferences(MSHTML::IHTMLWindow2Ptr wnd); Elem* addDocument(MSHTML::IHTMLDocument2* doc, MSHTML::IHTMLWindow2* wnd); Modified: trunk/sieve/src/LeakDlg.cpp =================================================================== --- trunk/sieve/src/LeakDlg.cpp 2006-08-14 09:55:51 UTC (rev 117) +++ trunk/sieve/src/LeakDlg.cpp 2006-08-14 14:22:30 UTC (rev 118) @@ -95,9 +95,10 @@ #define COL_ID 5 #define COL_ORPHAN 6 #define COL_LEAK 7 -#define COL_OUTERHTML 8 -#define COL_ADDRESS 9 -#define COL_SIZE 10 +#define COL_CYCLE 8 +#define COL_OUTERHTML 9 +#define COL_ADDRESS 10 +#define COL_SIZE 11 BOOL CLeakDlg::OnInitDialog() { CDialog::OnInitDialog(); @@ -116,6 +117,7 @@ m_leakList.InsertColumn(COL_ID, L"ID", LVCFMT_LEFT, 80); m_leakList.InsertColumn(COL_ORPHAN, L"Orphan", LVCFMT_LEFT, 50); m_leakList.InsertColumn(COL_LEAK, L"Leak", LVCFMT_LEFT, 40); + m_leakList.InsertColumn(COL_CYCLE, L"Cycle", LVCFMT_LEFT, 40); m_leakList.InsertColumn(COL_OUTERHTML, L"outerHTML", LVCFMT_LEFT, 800); m_leakList.InsertColumn(COL_ADDRESS, L"Address", LVCFMT_LEFT, 80); m_leakList.InsertColumn(COL_SIZE,L"Size", LVCFMT_LEFT, 50); @@ -256,6 +258,7 @@ // Leak if: !running && refcount > 0. m_leakList.SetItemText(idx, COL_ORPHAN, (getIsNodeOrphan(entry.elem)) ? L"Yes" : L""); m_leakList.SetItemText(idx, COL_LEAK, (!entry.hookElem->docElem->running && entry.refCount > 0) ? L"leak!" : L""); + m_leakList.SetItemText(idx, COL_CYCLE, ( entry.hookElem->cycleDetected ) ? L"cycle!" : L""); m_leakList.SetItemData(idx,(DWORD_PTR) &entry); if ( element ) @@ -633,6 +636,12 @@ if ( entry2->hookElem->docElem->running ) return -1 * g_sortOrder; return 0; + case COL_CYCLE: + if ( entry1->hookElem->cycleDetected == entry2->hookElem->cycleDetected ) return 0; + if ( entry1->hookElem->cycleDetected ) return 1 * g_sortOrder; + if ( entry2->hookElem->cycleDetected ) return -1 * g_sortOrder; + return 0; + case COL_ORPHAN: { BOOL elem1_isOrphan = elem1 ? getIsNodeOrphan(elem1) : false; Modified: trunk/sieve/src/sIEveHooks.js =================================================================== --- trunk/sieve/src/sIEveHooks.js 2006-08-14 09:55:51 UTC (rev 117) +++ trunk/sieve/src/sIEveHooks.js 2006-08-14 14:22:30 UTC (rev 118) @@ -69,32 +69,11 @@ } }; - window.__sIEve_clearClones = function(elem) + window.__sIEve_logDetectedCycle = function(elem) { - if ( elem.nodeType == 1 ) - { - elem.removeAttribute("cloneNode"); - elem.removeAttribute("__sIEve_nativeCloneNode"); - var child = elem.firstChild; - while ( child ) { - window.__sIEve_clearClones(child); - child = child.nextSibling; - } - } - } - - window.__sIEve_resetClones = function(elem) - { - if ( elem.nodeType == 1 ) - { - window.__sIEve_overloadCloneNode(elem); - var child = elem.firstChild; - while ( child ) { - window.__sIEve_resetClones(child); - child = child.nextSibling; - } - } - } + jsHook.logDetectedCycle(elem); + }; + var nativeCreateElement = window.document.createElement; window.document.createElement = function(tag) { var elem = nativeCreateElement(tag); @@ -103,6 +82,33 @@ }; } +function __sIEve_clearClones(elem) +{ + if ( elem.nodeType == 1 ) + { + elem.removeAttribute("cloneNode"); + elem.removeAttribute("__sIEve_nativeCloneNode"); + var child = elem.firstChild; + while ( child ) { + window.__sIEve_clearClones(child); + child = child.nextSibling; + } + } +} + +function __sIEve_resetClones(elem) +{ + if ( elem.nodeType == 1 ) + { + window.__sIEve_overloadCloneNode(elem); + var child = elem.firstChild; + while ( child ) { + window.__sIEve_resetClones(child); + child = child.nextSibling; + } + } +} + function __sIEve_setRescanForElementsTimeout() { window.navigator.__sIEve_rescanForElementsInterval *= 2; @@ -188,6 +194,7 @@ if ( sourceObject == object ) { sourceObject["_CIRCULAR REFERENCE: "+ referencePath] = "path = " + referencePath; + __sIEve_logDetectedCycle(sourceObject); } } else @@ -261,11 +268,6 @@ return false; // Don't scan <LINK> } } - if ( typeof(target.___sIEve_circularReference) != "undefined" ) - { - // Don't scan again circular references. - return false; - } var type = typeof(target); if ( type == "object" || type == "function" ) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |