Where is that Ajax.Request object created? In a function somewhere
that gets called over and over? If so, is there any particular reason
the success handler has to be an inline function? (I don't
immediately see it referencing anything outside of itself that it
would need to be a closure, for instance.) It shouldn't be a problem
provided nothing's holding on to the function or the Ajax.Request
after it completes, but that doesn't mean that the GC is going to be
perfect in every case and in fact Firefox 2 has several known leaks
around this stuff. I'd try this:
At global (page/script) scope:
function handleUpdateSuccess(transport){
var json = transport.responseText.evalJSON();
$('statusBanner').update();
$('Month1').update(responseJSON.Month1);
$('Month1V').update(json.Month1V);
$('Month2').update(json.Month2);
$('Month2V').update(json.Month2V);
$('Month3').update(json.Month3);
$('Month3V').update(json.Month3V);
$('L1V').update(json.L1V);
$('L2V').update(json.L2V);
$('L3V').update(json.L3V);
$('Spread1').update(json.Spread1);
$('Spread1V').update(json.Spread1V);
$('Spread2').update(json.Spread2);
$('Spread2V').update(json.Spread2V);
$('Spread3').update(json.Spread3);
$('Spread3V').update(json.Spread3V);
delete json;
}
function handleUpdateFailure()
{
$('statusBanner').update("<h1>Loading</h1>");
}
And then where your request is created:
new Ajax.Request('getData?time=' + dateTime,
{
method:'get',
onSuccess: handleUpdateSuccess,
onFailure: handleUpdateFailure
});
FWIW, might make no difference, might help.
--
T.J. Crowder
tj / crowder software / com
On Mar 8, 3:03 pm, abehrens <[EMAIL PROTECTED]> wrote:
> Greetings
>
> I have a javascript problem concerning a possible memory leak. I am
> using Ajax.Request to get a JSON object from a server and then passing
> the data from the JSON object to a few div's. This is done every
> second, but over time it seems my code leaks somewhere (in the
> browser).
>
> I have racked my brain trying to figure this one out...can anyone tell
> from this snippet what might be wrong:
> new Ajax.Request('getData?time=' + dateTime,
> {
> method:'get',
> onSuccess: function(transport){
> var json = transport.responseText.evalJSON();
> $('statusBanner').update();
> $('Month1').update(responseJSON.Month1);
>
> $('Month1V').update(json.Month1V);
> $('Month2').update(json.Month2);
> $('Month2V').update(json.Month2V);
> $('Month3').update(json.Month3);
> $('Month3V').update(json.Month3V);
>
> $('L1V').update(json.L1V);
> $('L2V').update(json.L2V);
> $('L3V').update(json.L3V);
>
> $('Spread1').update(json.Spread1);
> $('Spread1V').update(json.Spread1V);
> $('Spread2').update(json.Spread2);
> $('Spread2V').update(json.Spread2V);
> $('Spread3').update(json.Spread3);
> $('Spread3V').update(json.Spread3V);
> delete json;
>
> },
>
> onFailure: function(){
> $('statusBanner').update("<h1>Loading</h1>");
>
> }
> });
>
> Many many thanks in advance.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby
on Rails: Spinoffs" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/rubyonrails-spinoffs?hl=en
-~----------~----~----~----~------~----~------~--~---