The Problem is: you can't predict when the browsers garbage collector will do it's job and you can't trigger it. Try to reduce removing/ creating widgets but rather switching their's content(for example label's text or similar).
On 21 Okt., 23:24, David Ojeda <[EMAIL PROTECTED]> wrote: > Forgot to mention some things: > sIEve indicates that there are no memory leaks. However, it does show > that > there are unused DOM nodes (it also says they are orphaned). It seems > these > nodes are always an instance of the label. > > I understand that I am creating a new Label, and hence a new dom node, > every time > the user clicks the button. However, shouldn't it be garbage collected > after I remove > it from the panel? > > That's my main question... GWT docs indicate that they solve the > circular reference > problem and is very careful with memory leaks... but this simple > example > tells me otherwise. I really wish that I was wrong about this. > > Here is the info of one of the unused dom nodes according to > sIEve:http://192.168.1.100:8080/TestGWT-1.0-SNAPSHOT/testgroup.Application/... > (1 reference) > language > scrollHeight 0 > isTextEdit 0 > currentStyle [object] > document [object] > onmouseup > oncontextmenu > isMultiLine -1 > clientHeight 0 > onrowexit > onbeforepaste > onactivate > scrollLeft 0 > lang > onmousemove > onmove > onselectstart > parentTextEdit [null object] > oncontrolselect > canHaveHTML -1 > onkeypress > oncut > onrowenter > onmousedown > onpaste > className gwt-Label > id > onreadystatechange > onbeforedeactivate > hideFocus 0 > dir > isContentEditable 0 > onkeydown > clientWidth 0 > onlosecapture > parentElement [null object] > ondrag > ondragstart > oncellchange > recordNumber > onfilterchange > onrowsinserted > ondatasetcomplete > onmousewheel > ondragenter > onblur > onresizeend > onerrorupdate > onbeforecopy > ondblclick > scopeName HTML > onkeyup > onresizestart > onmouseover > onmouseleave > outerText this is a new label 66 > innerText this is a new label 66 > onmoveend > tagName DIV > title > offsetWidth 0 > onresize > contentEditable inherit > runtimeStyle [object] > filters (unknown) > ondrop > onpage > onrowsdelete > tagUrn > offsetLeft 0 > clientTop 0 > style [object] > onfocusout > clientLeft 0 > ondatasetchanged > canHaveChildren -1 > ondeactivate > isDisabled 0 > onpropertychange > ondragover > onhelp > ondragend > onbeforeeditfocus > disabled 0 > onfocus > behaviorUrns [object] > accessKey > onscroll > onbeforeactivate > onbeforecut > readyState complete > all [object] > sourceIndex 0 > onclick > scrollTop 0 > oncopy > onfocusin > tabIndex 0 > onbeforeupdate > outerHTML > <DIV class=gwt-Label __sIEve_hookedNode="true" __listener="null">this > is a new label 66</DIV> > innerHTML this is a new label 66 > ondataavailable > offsetHeight 0 > onmovestart > onmouseout > scrollWidth 0 > offsetTop 0 > onmouseenter > onlayoutcomplete > offsetParent [null object] > onafterupdate > ondragleave > children [object] > parentNode [object] > ownerDocument [object] > firstChild [object] > lastChild [object] > childNodes [object] > nextSibling [null object] > align > dataFormatAs > dataSrc > nodeName DIV > noWrap 0 > nodeValue > nodeType 1 > previousSibling [null object] > attributes [object] > dataFld > cloneNode [object] > __listener > > On Oct 22, 4:12 pm, David Ojeda <[EMAIL PROTECTED]> wrote: > > > Hello all, > > > I am having some serious problems with a big application that is using > > a lot of the browser's memory (Internet Explorer 6 and 7). > > It is a single page that constantly > > removes/adds widgets to panels, so it doesn't navigate to external > > links. It uses a 3rd party lib: gwt-ext, so this is my primary > > suspect. > > > However, I analyzed the application with sIEve > > (http://home.wanadoo.nl/jsrosman/), and I think that removing and > > adding widgets dinamycally to panels could be one cause of my > > problems. > > > I created the following test: > > > package testgroup.client; > > > import com.google.gwt.core.client.EntryPoint; > > import com.google.gwt.user.client.ui.Button; > > import com.google.gwt.user.client.ui.ClickListener; > > import com.google.gwt.user.client.ui.Label; > > import com.google.gwt.user.client.ui.Panel; > > import com.google.gwt.user.client.ui.RootPanel; > > import com.google.gwt.user.client.ui.SimplePanel; > > import com.google.gwt.user.client.ui.Widget; > > > public class Application implements EntryPoint { > > > private boolean added = false; > > private Widget mywidget = null; > > private int counter = 0; > > > /** > > * This is the entry point method. > > */ > > public void onModuleLoad() { > > > final Panel mypanel = new SimplePanel(); > > final Button mybutton = new Button("Add or remove label"); > > > mybutton.addClickListener(new ClickListener() { > > public void onClick(Widget arg0) { > > if (added) { > > mypanel.remove(mywidget); > > mywidget = null; // just in case > > } else { > > mywidget = new Label("this is a new label "+ > > (counter++)); > > mypanel.add(mywidget); > > } > > added = !added; > > } > > }); > > > RootPanel.get().add(new Label("Leak example")); > > RootPanel.get().add(mybutton); > > RootPanel.get().add(mypanel); > > } > > > } > > > When testing with sIEve, it says that this generates 38 DOM nodes and > > ~7512 kb of memory. Every time I click the button in order to add a > > label to the panel, a new DOM node is created and the memory increases > > by some kb (sometimes 4kb, 20kb, I don't see a pattern). But when I > > click again > > to remove it, neither the number of DOM nodes decreases nor the > > memory. > > > What is going on here? > > > I also tested with a timer: > > > Timer timer = new Timer() { > > public void run() { > > if (added) { > > mypanel.remove(mywidget); > > mywidget = null; // just in case > > } else { > > mywidget = new Label("this is a new label "+ > > (counter++)); > > mypanel.add(mywidget); > > } > > added = !added; > > } > > }; > > timer.scheduleRepeating(500); > > > But in this case, the DOM and memory are stable! > > I am really confused here, this is obviously not my application, but > > my application does a lot of add/remove of much more complicated > > widgets that consume some space. > > > I am using GWT-1.4.61, but the same behaviour is happening with 1.5.2. > > > Please, does anyone have any ideas on this? > > > Thanks > > > David > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/Google-Web-Toolkit?hl=en -~----------~----~----~----~------~----~------~--~---
