obj = null; //可以释放该对象占用的内存

解决方案 »

  1.   

    obj= null
    你的什么代码,拿来看看
      

  2.   

    并不是无限制的消耗内存
    只是一个有帧结构的页面不断跳转
    如果你打开一个IE窗口,在不关闭窗口的情况下不断浏览不同页面,IE的内存占用也很难会降下来obj= null
    并不会强制IE回收内存我试过以下脚本
    <script>
    var a=new Array();
    for (i=0;i<100000;i++){
    a[i]="这是一段长1K以上的字符串";
    }function hh(){
    for (i=0;i<100000;i++){
    a[i]=null;
    }
    a=null;
    }
    </script>
    <input type=button value="jjjj" onclick="hh()">在点击按钮后任务管理器中iexplore.exe的内存使用一点儿都没降
      

  3.   

    object = null是说明你这个东东可以被回收
    但并不是马上回收就像你在JAVA中调用gc(),他并不会按照你的意愿马上进行
    他还是按照他本身的逻辑进行处理先不用跳转看看占用多少内存
    如果是不停的跳转内存越来越大就看你代码有没有问题
      

  4.   

    谢谢,我已经找到了JScript uses a -and-sweep garbage collector with a variety of heuristics used to determine when to run garbage collection. The JScript garbage collector works like this:1、When the script engine is shut down, garbage is collected.2、When 256 variants, or more than 64KB of strings, or more than 4096 array slots have been allocated, the garbage collector sets a flag that says collect soon.3、Whenever a new statement is executed or the script debugger starts, that flag is checked, and if it is set, a collection is done.There is an undocumented JScript function called CollectGarbage that forces a garbage collection. This is for testing purposes only—do not ship code that calls this function. It is a poor programming practice to write code in JScript that depends on garbage collections being done at particular times. If you need predictable garbage collection, use a language that supports it (like Visual Basic? or VBScript). Note that all of this is the implementation detail of the engine and should not be relied upon because it may change in the future. Note also that the version of JScript supported by Microsoft? .NET will use the .NET Framework garbage collector, a multigenerational -and-sweep collector.
    And remember, if you want a deterministic-lifetime app, use a deterministic-lifetime language like C++, Visual Basic 6.0, or VBScript; not an indeterministic-lifetime language like JScript, Scheme, or Java. If you're writing a program that depends on being able to have a deterministic object lifetime, JScript is not the right tool for the job. Trying to make it a deterministic-lifetime language will just create headaches down the road.
    我试着在obj= null的最后加上CollectGarbage();
    确实能够立刻回收,就是不知道CollectGarbage()在以后的script版本里会变成什么样
    唉,没办法,只好先用着了!!
    谢谢二位了