1 /* Licensed to the Apache Software Foundation (ASF) under one or more 2 * contributor license agreements. See the NOTICE file distributed with 3 * this work for additional information regarding copyright ownership. 4 * The ASF licenses this file to you under the Apache License, Version 2.0 5 * (the "License"); you may not use this file except in compliance with 6 * the License. You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 /* 17 * Author: Werner Punz (latest modification by $Author: werpu $) 18 * Version: $Revision: 1.4 $ $Date: 2009/05/31 09:16:44 $ 19 */ 20 21 /** 22 * @class 23 * @name _FinalizeableObj 24 * @memberOf myfaces._impl.xhrCore 25 * @description A helper class which supports IE with its non working garbage collection. 26 * @see <a href="http://msdn.microsoft.com/en-us/library/bb250448%28VS.85%29.aspx">http://msdn.microsoft.com/en-us/library/bb250448%28VS.85%29.aspx</a> 27 * @see <a href="http://weblogs.java.net/blog/driscoll/archive/2009/11/13/ie-memory-management-and-you">http://weblogs.java.net/blog/driscoll/archive/2009/11/13/ie-memory-management-and-you</a> 28 * @see <a href="http://home.orange.nl/jsrosman/">http://home.orange.nl/jsrosman/</a> 29 * @see <a href="http://www.quirksmode.org/blog/archives/2005/10/memory_leaks_li.html">http://www.quirksmode.org/blog/archives/2005/10/memory_leaks_li.html</a> 30 * @see <a href="http://www.josh-davis.org/node/7">http://www.josh-davis.org/node/7</a> 31 */ 32 myfaces._impl.core._Runtime.extendClass("myfaces._impl.xhrCore._FinalizeableObj", Object, 33 /** @lends myfaces._impl.xhrCore._FinalizeableObj.prototype */ 34 { 35 36 _resettableContent: null, 37 38 constructor_: function() { 39 this._resettableContent={}; 40 }, 41 42 _initDefaultFinalizableFields: function() { 43 for(var key in this) { 44 //per default we reset everything which is not preinitalized 45 if(null == this[key] && key != "_resettableContent" && key.indexOf("_mf") != 0 && key.indexOf("_") == 0) { 46 this._resettableContent[key]=true; 47 } 48 } 49 }, 50 51 /** 52 * ie6 cleanup 53 * This method disposes all properties manually in case of ie6 54 * hence reduces the chance of running into a gc problem tremendously 55 * on other browsers this method does nothing 56 */ 57 _finalize: function() { 58 if (!myfaces._impl.core._Runtime.browser.isIE || !this._resettableContent) { 59 //no ie, no broken garbage collector 60 return; 61 } 62 63 for(var key in this._resettableContent) { 64 if (myfaces._impl.core._Runtime.exists(this[key],"_finalize")) { 65 this[key]._finalize(); 66 } 67 delete this[key]; 68 } 69 } 70 });