java - VisualVM OQL: find object that has (indirect) reachables/references to two object IDs? -


my question rather short , compact:

if find 2 objects visualvm, kind of oql query can perform find objects have (indirect) reachables or references these 2 objects?

update jb:

after editing code, came following:

//query script: find object (indirectly) references target objects     //list objects objects search should (indirectly) refer     var targetobjects =     [   heap.findobject("811819664"), //eg. obj contains player's health                     heap.findobject("811820024") //eg. obj contains same player's name                 ];      //list objects here every or objects have indirect referer (eg. base class loaders)     var ignorereferers =    []; //eg. [heap.findobject("ignid1")];      //set array elements refer each target object     var targetobjectsreferers = [];     (var tarobjindex in targetobjects) {         var targetobjrefelements = [];          //get live path of target object         var livepaths = heap.livepaths(targetobjects[tarobjindex]);          //cleanup every live path         (var livepathsindex in livepaths) {             var curlivepath = livepaths[livepathsindex];             if ((curlivepath == null) || (curlivepath == "undefined")) continue;              //remove last element live path actual object             curlivepath.pop();              //remove elements equal ignore referer object             (var pathelementindex in curlivepath) {             if ((curlivepath[pathelementindex] == null) || (curlivepath[pathelementindex] == "undefined")) continue;                  (var ignoreindex in ignorereferers) {                     if (identical(curlivepath[pathelementindex], ignorereferers[ignoreindex])) curlivepath.splice(pathelementindex, 1); //fixme: might fail if index not updated                 }             }                }          //merge remaining life paths elements targetobjrefelements         (var livepathsindex in livepaths) {             var curlivepath = livepaths[livepathsindex];              (var curlivepathindex in curlivepath) {                 targetobjrefelements.push(curlivepath[curlivepathindex]);             }         }          //remove duplicate referers         targetobjrefelements = unique(targetobjrefelements, 'objectid(it)');          //add target objects referers         targetobjectsreferers.push(targetobjrefelements);     }      //filter , return     filter(targetobjectsreferers[0], function(it1) {         var rslt = contains(targetobjectsreferers[1], function(it2) { //fixme: limits 2 objects!             return identical(it1, it2);         });         return rslt;     }); 

this returns pop not defined error after while, trying resolve. if manage resolve can see if provides expected results.

it sounds trying reference chains keeping objects alive. can use heap.livepaths(object) function obtain them. can take hints following code

var paths1 = heap.livepaths(heap.findobject("1684177040")) // use objectid of first instance var paths2 = heap.livepaths(heap.findobject("1684177160")) // use objectid of second instance  var patharr1 = unique(rcs2array(paths1), 'objectid(it)') // flatten livepaths single array of instances var patharr2 = unique(rcs2array(paths2), 'objectid(it)') // same second instance  // calculate arrays' intersection - result set of object keeping both of instances alive filter(patharr1, function(it1) {    var rslt = contains(patharr2, function(it2) {      return (objectid(it1) == objectid(it2))   })   return rslt })  // helper function convert array of reference chains flat array of objects function rcs2array(rcs) {   var arr = new array()    for(var i=0;i<rcs.length;i++) {     var rc = rcs[i];     for(var j=0;j<rc.length;j++) {         arr.push(rc[j])     }   }   return arr } 

please, bear in mind works in visualvm , jhat


Comments

Popular posts from this blog

apache - Add omitted ? to URLs -

redirect - bbPress Forum - rewrite to wwww.mysite prohibits login -

php - How can I stop spam on my custom forum/blog? -