473,549 Members | 2,733 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Yahoo! UI AJAX IE memory leak workaround and justification

Hi,

Reading the Yahoo! UI AJAX library, there is a unique workaround for an
apparent IE 6 memory leak with binding a function to
onreadystatecha nge. Instead of binding a function to
onreadystatecha nge, the library polls the readystate of the request
object until it becomes 4. Then it calls the handler function. This
polling seems like a lot of work but maybe is a good approach? If bad
then what is better? Another person asked about this on the Yahoo! UI
mailing list. I am interested what some more experienced folks think
about the workaround justification from the author of the library.

<quote author="Thomas Sha"
url="http://tech.groups.yah oo.com/group/ydn-javascript/message/973">
In IE, JavaScript is managed by a "mark and sweep" collector, while
DOM/ActiveX is managed by reference counting. With onreadystatecha nge,
a closure is created which references the XHR object (e.g., XHR.event
-closure -callback -XHR), hence they are pointing to each other.
IE fails to reclaim the allocated memory even though both the
JavaScript object and the DOM/ActiveX object are "dead".

The traditional fix for IE has been to point onreadystatecha nge to an
empty, stub function when the transaction is completed; you cannot
explicitly detach this event handler with "null" in IE < 7. I'm not
fully convinced this works.

The polling mechanism avoids explicitly binding onreadystatecha nge, and
instead looks at the readystate of the transaction. It is an
unorthodox attempt to avoid memory leaks in IE through the event
handler.
</quote>

Thanks,
Peter

Sep 13 '06 #1
6 2231
pe**********@gm ail.com wrote:
Hi,

Reading the Yahoo! UI AJAX library, there is a unique
workaround for an apparent IE 6 memory leak with binding
a function to onreadystatecha nge. Instead of binding a
function to onreadystatecha nge, the library polls the
readystate of the request object until it becomes 4.
Then it calls the handler function. This polling seems
like a lot of work but maybe is a good approach? If bad
then what is better? Another person asked about this on
the Yahoo! UI mailing list. I am interested what some
more experienced folks think about the workaround
justification from the author of the library.
The usual approach to IE's circular reference memory leak problems is to
break the circles. The onreadystatecha nge property of the xml http
request object can be set to any harmless function from a scope above
the XML http request object after the handler handles the response, and
the reference to the xml http request object can be removed from the
handler's scope chain by assigning null to the variable that references
it. The same would have to be done if the page unloaded prior to the
completion of the request (along with aborting any pending requests).

<snip>
The traditional fix for IE has been to point onreadystatecha nge
to an empty, stub function when the transaction is completed;
you cannot explicitly detach this event handler with "null" in
IE < 7. I'm not fully convinced this works.
It should work, but also removing the reference to the xml http request
object from the old handler's scope chain cannot do any harm. Any
breaking of the circle will do, but fully isolating the two object from
each other should make it clearer that the are both independently
available for garbage collection.
The polling mechanism avoids explicitly binding
onreadystatecha nge, and instead looks at the readystate
of the transaction. It is an unorthodox attempt to avoid
memory leaks in IE through the event handler.
</quote>
I would want to see code that demonstrated that there was an issue
following the removal of the onreadystatecha nge handler, it may (if
demonstrated) turn out to be related to some coincidental factor unknown
to the Yahoo developers. Saying something is so is not the same as
showing that it is so.

Richard.
Sep 13 '06 #2
pe**********@gm ail.com wrote:
Hi,

Reading the Yahoo! UI AJAX library, there is a unique workaround for an
apparent IE 6 memory leak with binding a function to
onreadystatecha nge. Instead of binding a function to
onreadystatecha nge, the library polls the readystate of the request
object until it becomes 4. Then it calls the handler function. This
polling seems like a lot of work but maybe is a good approach? If bad
then what is better?
What better answers there might be, sorta depends on your development
context and your overall goals with browser background transactions.

We ourselves have some rather far reaching goals so there is likely to
be some digressions , but it is a rather large canvas that spawned our
approach

I'll give you the nickel tour of the direction we took
in developing reliable interfaces, and others I'm sure
will have additional thoughts that should give you some options
and inspirational input.

Our basic day to day browser background transactions
revolve around MySQl,WSDL,REST ,RSS,General XML, XSLT and I guess
this season we are adding ATOM and NNTP transactions too.
[ no rest for the wicked :) ]

All the interfaces on our server return JASONized XML
as javascript including a user definable javascript callback function.
and our javascript *throbber* callback mechanism that manages
retry cycles. (Defaults to 3 retries)
I program via Direcway satellite so the connection can get sketchy
and thus the throbber code gets a good workout

The requests themselves are not made via AJAX, but rather
simple xbrowser DOM manipulations involving dynamically created
<scriptnodes with the queries encoded into the src attribute. invoked
by code like new LAMPtransact({i d:"WSDL",cgi:"F 1WSDL.cgi",args :szArgs})
we use this one javascript class to call any of the services we interact
with

Being as all our returns are JASONized XML we use a lot of
dynamic in browser XSL transforms to sling the XML against
an XSL file and fill the target divs with pretty UI
without hard coding same.

(in the voice of a late night infomercial ) "But thats not all !!!"

Any page we automate in this fashion no matter how many widgets
it uses now or in the future nor what domain the page
only needs but *a single <scripttag*.

We load our widgets via class attributes as in this simple
example that puts a WSDL based Google search in a page, anywhere
on any server including yours (cross domain javascript like Googlemaps).

<div class="wPoint_s earch" />

(in the voice of a late night infomercial ) "But thats not all !!!"

We are also installing some other CSS legal trickery to cue
forms field validation and UI augmentation to support XML data types
and other UI stuff like HTML capable <textarea>s with but
that same single script tag and simple CSS entries.






Sep 14 '06 #3
drclue said the following on 9/13/2006 9:25 PM:

<snip>
The requests themselves are not made via AJAX, but rather
simple xbrowser DOM manipulations involving dynamically created
<scriptnodes with the queries encoded into the src attribute.
Nothing fancy about that. It is so simple it is trivial to do.

<snip>
Any page we automate in this fashion no matter how many widgets
it uses now or in the future nor what domain the page
only needs but *a single <scripttag*.
I hope that is not intended to attempt to be impressive or anything
because its not that impressive. The only reason to use more than one
script tag is to reference external files or inline document.write
statements. But, just for fun, I will trump you and say I can write a
dynamically JS driven page without a script tag at all in the HTML code
itself.

<body onload="
loadScript=docu ment.createElem ent('script');
loadScript.type ='text/javascript';
loadScript.src= 'someOtherJSFil e.js';
document.getEle mentsByTagName( 'head')[0].appendChild(lo adScript);
">

Then, someOtherJSFile .js could contain code that is used in the page.

As I said, it's trivial and boasting of "only needs but a single script
tag" isn't saying much.

--
Randy
Chance Favors The Prepared Mind
comp.lang.javas cript FAQ - http://jibbering.com/faq & newsgroup weekly
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Sep 14 '06 #4
Randy Webb wrote:
drclue said the following on 9/13/2006 9:25 PM:

<snip>
>The requests themselves are not made via AJAX, but rather
simple xbrowser DOM manipulations involving dynamically created
<scriptnodes with the queries encoded into the src attribute.

Nothing fancy about that. It is so simple it is trivial to do.
Actually , that's the idea, to keep the javascript trivial,
so that those coding in javascript can yawn.

Using CSS class and style entries for loading and running libraries
although trivial code , is important in allowing even those who
do just HTML to yawn at the effort required.

On the other side of that nice trivial yawn evoking interface
things get at least a little more interesting where a single
object orientated set of C++ source code manifests it self
as various WSDL,XML,MySql and other interfaces to local and remote
resources. Some of these take the form of forking servers with
shared memory run level , and virtual domain support.

While I'm sure this is probably trivial to you as well,
for many it is not so trivial, and for many it's impossible.

Also it was clearly expressed that there were probably
many folks like yourself that would have other positive thoughts to
contribute.

I'm sure you've probably already posted that positive,
and constructive reply to the original posters question. :)


Sep 14 '06 #5
drclue said the following on 9/14/2006 12:22 AM:
Randy Webb wrote:
>drclue said the following on 9/13/2006 9:25 PM:

<snip>
>>The requests themselves are not made via AJAX, but rather
simple xbrowser DOM manipulations involving dynamically created
<scriptnode s with the queries encoded into the src attribute.

Nothing fancy about that. It is so simple it is trivial to do.

Actually , that's the idea, to keep the javascript trivial,
so that those coding in javascript can yawn.
Just the idea of my programmers yawning while they type gives me the creeps.
Using CSS class and style entries for loading and running libraries
although trivial code , is important in allowing even those who
do just HTML to yawn at the effort required.
Using CSS to import JS, or, to execute server side scripts?

--
Randy
Chance Favors The Prepared Mind
comp.lang.javas cript FAQ - http://jibbering.com/faq & newsgroup weekly
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Sep 14 '06 #6
Randy Webb wrote:
drclue said the following on 9/14/2006 12:22 AM:
>Randy Webb wrote:
>>drclue said the following on 9/13/2006 9:25 PM:

<snip>

The requests themselves are not made via AJAX, but rather
simple xbrowser DOM manipulations involving dynamically created
<scriptnod es with the queries encoded into the src attribute.

Nothing fancy about that. It is so simple it is trivial to do.

Actually , that's the idea, to keep the javascript trivial,
so that those coding in javascript can yawn.

Just the idea of my programmers yawning while they type gives me the
creeps.
Well, if one can convert the small stuff to yawns, then
that leaves more room for the really fun stuff where nobody
would be yawning!
>Using CSS class and style entries for loading and running libraries
although trivial code , is important in allowing even those who
do just HTML to yawn at the effort required.

Using CSS to import JS, or, to execute server side scripts?
Either one is possible, although the more common use for me
is to have <element class="wPoint_x xxx" /result in
the post page load injection of library wLIB_xxxx.js with flags
in said file resulting in the loading optional wLIB_xxxx.(xml, css,xslt)
imports if indicated. Another variation involves form field validation
and UI augmentation for xml scheama and specialty controls
like HTML editors.

Sep 14 '06 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

13
17816
by: dan roberts | last post by:
Folks, This is my first Python project so please bear with me. I need to download data from Yahoo Finance in CSV format. The symbols are provided in a text file, and the project details are included below. Does anyone have some sample code that I could adapt? Many thanks in advance, dan
6
4701
by: Travis | last post by:
Can someone give me an example of connecting to yahoo's smtp server and sending mail? I'm doing this: msg = MIMEText(self.text_ctrl_1.GetValue()) msg = sub msg = 'bossierbossman@yahoo.com' msg = to s = smtplib.SMTP('smtp.mail.yahoo.com') s.set_debuglevel(1) s.connect()
11
1944
by: Brett | last post by:
In Yahoo mail, I click the Inbox link and see my messages. If I view source, I don't have HTML which contains the URL of each message. The source HTML contains javascripting and framesets. This is different from what I am seeing. If I right click on a message link and select "copy shortcut", I can paste this link into my browser. This...
6
5052
by: erdem kemer | last post by:
i cant send mail to yahoo mail or hotmail while i can send my other mail accounts (pop3) is it becouse yahoo and hotmail is web-based mail here is the code MailMessage mailMsg = new MailMessage(); mailMsg.From = from; from = from + from;
7
2492
by: Mahesh Devjibhai Dhola | last post by:
Hi, I want to develop p2p (peer-to-peer) communication connection for chat in ..Net (Lang: c# - preferable) NOTE: if two LAN are behind their own router then also it should work as yahoo, msn messenger works. Let me explain scenario: In yahoo: - We login to yahoo server from yahoo messenger (yahoo server listens at
4
3687
by: joe_public34 | last post by:
Hello all, I'm trying to write a script to log into Yahoo! (mail, groups, etc), but when I pass the full URL with all form elements via Python, I get a resutling 400 - Bad Request page. When I just plop the full URL into a browser, it works perfectly. Is there something I need to specify in python to submit the correct info (headers, user...
2
1363
by: Dave Lee | last post by:
My apologies for probably being in the wrong group, but there does seem to be some discussion possibly related to my problem. I have a typical, personalized "my.yahoo" page and recently most all of the newsfeeds are no longer updated. It happens on IE and Firefox, doesn't matter if I am looking at my personalized page or if I log out and go to...
0
2667
by: Page O Rama | last post by:
Hi, R U BLOCKED ON MSN,YAHOO,ICQ OR AOL Messenger By Your Friend, Then What are you waiting for.Visit one of the link below to find out who has blocked you in his/her friend list. MSN Block Checker: http://www.telepk.com/msn-messenger/msn-block-checker/ Yahoo Block Checker:
1
3589
by: Andrew | last post by:
Hello, friends, I am implementing web app security using asp.net 1.1, and I found the following source code from Yahoo! Mail login page: <form method="post" action="https://login.yahoo.com/config/login?" autocomplete="off" name="login_form"> <input type="hidden" name=".tries" value="1"> <input type="hidden" name=".src" value="ym">...
1
2028
by: PeterAlt | last post by:
I have a Yahoo store. In order for me to access via javascript or HTML (on the client side) any information stored in Yahoo's product fields, I have to use something that looks like this... <!--#ystore_catalog id=neo2-digital field=name --> Where "id=" follows the product name. "field=" follows the information field stored on Yahoo's servers...
0
7720
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
7960
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7475
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
1
5372
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5089
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3501
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3483
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1944
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
0
766
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.