Ace.Tern icon indicating copy to clipboard operation
Ace.Tern copied to clipboard

Memory leak

Open RajeshParekatta opened this issue 8 years ago • 0 comments

Usage of ace.tern in dynamic tab creation is resulting in tremendous memory increase. The memory used for an editor in a tab will not be cleared, when the editor gets destroyed, this results in crashing the browser object.

A sample code used for the dynamic creation and termination of an editor

aceEditor = { append : function(editor,tabId){

        var useWebWorker = true;
        editor.getSession().setUseWorker(useWebWorker);
        editor.session.setMode("ace/mode/javascript");
        editor.getSession().setUseWrapMode(true);
        editor.getSession().setWrapLimitRange(null, null);
        editor.setShowPrintMargin(false);

        ace.config.loadModule('ace/ext/language_tools', function() {
            ace.config.loadModule('ace/ext/tern', function() {
                editor.setOptions({
                    enableTern: {
                        defs: ['browser', 'ecma5', 'ourData'],
                        plugins: {
                            doc_comment: {
                                fullDocs: true
                            }
                        },
                        useWorker: useWebWorker,
                        switchToDoc: function(name, start) {
                            console.log('switchToDoc called but not defined. name=' + name + '; start=', start);
                        },

                        startedCb: function() {
                            console.log('editor.ternServer:', editor.ternServer);
                        },
                    },
                    enableSnippets: false,
                    enableBasicAutocompletion: true,
                });
            });
        });

        // Append editor into tabs using "tabId"
    },
remove : function(editor,tabId){
        editor.setSession(null);
        editor.destroy();
        // Remove tab from tabs using "tabId"
}

}

RajeshParekatta avatar Mar 15 '16 12:03 RajeshParekatta