1

別の日に見つけたメモリプール機能を使用して、アンドロイドのメモリを解放する解決策を見つけようとしています。私の問題は、それを実装する方法がわからないことです。その関数を呼び出す方法と、window.children オブジェクトを渡す方法。これが私が見つけた元の関数です:

var MemoryPool = function() {
    var _window;
    /*
     Here we make our "auto-release" pool. It's simply a window.
     We hide it upon creation so it won't interfere with our view hierarchy.

     5/3/2011: It seems that the window does not need to be a subcontext, just a regular window will do.
     */
    this.init = function() {
        _window = Ti.UI.createWindow();
        _window.hide();
        _window.open();
    }
    // This is where we clear out the memPool by closing it then reopening it again.
    this.clean = function(obj) {
        if(obj instanceof Array) {
            var arLen=obj.length;
            for ( var i=0, len=arLen; i<len; ++i ) {
                // We then stick the entire view into the pool
                _window.add(obj[i]);
            }
        } else {
            // We then stick the entire view into the pool
            _window.add(obj);
        }
        Ti.API.info('Cleaning MemoryPool.');

        // We empty the pool by closing it.
        _window.close();

        // We recreate the window again for the next object
        this.init();
    };
    this.init();
}

単純なウィンドウとその中に数人の子供がいるとしましょう。Shell 最初に MemoryPool を呼び出すか、または MemoryPool(obj) のようなものを渡す必要があります

誰かがそれについてもっと良い考えを持っているなら、ありがとう。

4

0 に答える 0