out of memory firebug error - firefox 3

out of memory firebug error - firefox 3


Hello all,
I am using the following function to show/hide content on page load
but every now and again it stops working with an out of memory error,
if I refresh the page it fixes it but it will happen again after 5 to
10 clicks on the image to toggle the state, any ideas on what I have
done wrong?
I am using the cookies plugin for remembering the state as well as UI
effects for animation on changing the state.
I am calling the function using
$("div.leftBoxContainer").collapse( {animation:"highlight" });
(function() {
jQuery.fn.collapse = function(settings) {
var cContainers = this;
settings = jQuery.extend({
header: "h3",
content: ".sideBoxContent, .box_more_link",
expandIcon: "images/plus_icon.gif",
collapseIcon: "images/minus_icon.gif"
}, settings);
return cContainers.each(function(){
var jDomElem = this;
var headerDomElem = jQuery(settings.header, jDomElem);
var contentDomElem = jQuery(settings.content, jDomElem);
headerDomElem.click(function() {
if(contentDomElem.css("display")=="none") {
    iconImgSrc = settings.collapseIcon;
    $.cookieJar('sideBox').remove(contentDomElem.parents().attr("id"));
} else {
    iconImgSrc = settings.expandIcon;
    $.cookieJar('sideBox').set(contentDomElem.parents().attr("id"),
'closed');
}
jQuery(this.firstChild).attr("src", iconImgSrc);
contentDomElem.toggle(settings.animation);
});
if(contentDomElem.css("display")=="none") {
    iconImgSrc = settings.expandIcon;
} else {
    iconImgSrc = settings.collapseIcon;
}
var expandIconDomElem = headerDomElem.prepend('<img src="' +
iconImgSrc + '" alt="" class="showhide" />');
contentDomElem.show();
var leftBox = $.cookieJar('sideBox');
    $.each(leftBox.toObject(), function(i, val) {
     if (val == 'closed') {
     $('#'+i+' .sideBoxContent').hide();
     }
    });
});
};
})(jQuery);
any help is well appreciated, thanks, Ant.