java - GWT Garbage Collection on unused Widgets? -


i interested in question when , if gwt garbage collection triggered in following example.

i have composite:

class extends composite implements hasclickhandlers {    ...    focuspanel panel = new focuspanel();      @override     public handlerregistration addclickhandler(clickhandler handler) {         return focuspanel.addclickhandler(handler);     }   } 

in view class create widget add click handler , add widget panel:

a widget = new a(); widget.addclickhandler(someclickhandler); somepanel.add(widget); 

at point in application clear panel have entered widget. widget not attached dom anymore , there no reference pointing on widget.

void removeall() {    somepanel.clear(); } 

what happens widget , click handler. gwt garbage collection takes care of it? have save handler registration , remove click handler myself?

one of advantages widget system manages of these memory issues you. provided combined widgets adding them other widgets (and never use getelement().appendchild(...), etc), handlers automatically wired dom when attached, , unwired when either detached or page unloaded.

this means treat widgets normal objects - if aren't attached page anymore , don't hold reference them, correctly garbage collected no matter browser.

the particular memory leaks referring problem in older browsers - modern webkit/gecko (chrome/safari/opera , firefox) not have these problems, nor ie 10 or 11.

check out http://www.gwtproject.org/articles/dom_events_memory_leaks_and_you.html deeper discussion of how widgets implement memory leak prevention code.


Comments

Popular posts from this blog

python - Subclassed QStyledItemDelegate ignores Stylesheet -

java - HttpClient 3.1 Connection pooling vs HttpClient 4.3.2 -

SQL: Divide the sum of values in one table with the count of rows in another -