Saturday, July 16, 2011

Browser/Javascript Memory leaks with setTimeout

It's been some time since I have been working on the OpenAnimator project, but recently I observed a strange memory leak. After drilling down into a lot of the javascript, I found the problem with a snippet of code that was something like this:


a = function() {
    try {
       
    setTimeout('a()',1);
    }catch(e) { error(e); }
};
a();

At first look this looks like a fairly, okay bit of code, and not any variables were being created except the setTimeout call. After a lot of google hunting here is what I have now:

a = function() {
    try {
       
    setTimeout(function() {a();},1);
    }catch(e) { error(e); }
}
a();


Apparently this solved the problem (atleast it appears so now). I am still not able to figure out why there was a problem with the earlier code. the 'a()' is causing a implicit eval to be executed, but how that leads to memory leaks is still unknown to me. I hope I'll get this one someday.

Monday, July 11, 2011

OIM - Find resources assigned to user

Wanna dig through OIM (Oracle Identity Manager) for resources assigned to users? Here is a query to solve it:

SELECT DISTINCT oiu.oiu_key,
  oiu.req_key,
  oiu.oiu_offlined_date,
  obi.obi_key,
  obi.obi_status, obj.obj_key,
  obj.obj_name,
  orc.orc_key,
  orc.orc_create,
  orc.orc_update,
  orc.orc_status, orc.orc_tos_instance_key,
  ORC_TASKS_ARCHIVED,
  ost_status,
  obj.sdk_key     AS OBJECTFORMKEY, '0' AS OBJECTFORMCOUNT,
  objsdk.sdk_name AS OBJECTFORMNAME, tos.sdk_key AS PROCESSFORMKEY,
  '0'             AS PROCESSFORMCOUNT, procsdk.sdk_name AS PROCESSFORMNAME,
  oiu.oiu_serviceaccount
FROM obj obj
LEFT OUTER JOIN sdk objsdk
ON obj.sdk_key=objsdk.sdk_key, oiu oiu
LEFT OUTER JOIN orc orc
ON oiu.orc_key=orc.orc_key
LEFT OUTER JOIN tos tos
ON orc.tos_key=tos.tos_key
LEFT OUTER JOIN sdk procsdk
ON tos.sdk_key=procsdk.sdk_key,  obi obi,  ost ost
WHERE oiu.obi_key=obi.obi_key
AND oiu.ost_key  =ost.ost_key
AND obi.obj_key  =obj.obj_key
AND oiu.usr_key IN (

select usr_key from usr where usr_status = 'Active'


)




This query will show you the same result as getObjects API call for all active OIM users.