Friday, August 27, 2010

Re: Memory Leak IE7 & GWT 2.0.4

Guys please help,

I'm passing throuth the same problem, the moderator from smargwt forum told me to
call destroy() in components that i don't need anymore, but my architecture uses MVP,
and i have only one container which changes the content to render diferent pages...
when I call destroy() in him and then I put the new component, he doesn't render anymore.

I have an aplication getting into production and I am passing throuth memory leak crashes on
browser... If someone can help me, pliz help.

I'm desperate,
--
Marcos Paulo Damasceno
Desenvolvedor Java
(85) 8140-0111
Twitter: www.twitter.com/_marcospaulo_
Del.ici.ous:
www.delicious.com/marcospaulo_
MSN: 
marcospaulodamasceno@hotmail.com

------------------------------------------------------------------------------------------------------------------------
"Grandes resultados requerem grandes ambições."
(Heráclito)

"Se suas ações inspiram outros a sonhar mais, aprender mais, fazer mais, tornar-se mais, você é um líder."
(John Quincy Adam)

"Se tudo fosse perfeito, amanhã não poderia ser melhor"



2010/8/27 chrisr <chris.robert.rowland@gmail.com>
Sorry for posting this twice.  If a moderator wants to/can remove the
duplicate go ahead.

On Aug 25, 2:56 pm, chrisr <chris.robert.rowl...@gmail.com> wrote:
> I created a simple application in an attempt to reproduce a memory
> leak issue in our decently large GWT application.
>
> This test application basically contains a split panel with a button
> on the left, and a tab panel full of large blocks of text on the
> right.
> Clicking the reload button fires the reloadRight method, and does a
> panel.clear() to remove the old tab panel and a  panel.add() to add a
> new tab panel to the right panel.  Doing this repeatedly causes memory
> consumption to increase without bounds.
>
> For example, on the initial load IE7 uses around 35 MB.  125 clicks
> later its using nearly 1.5GB.
>
> Is this example doing something in a fundamentally incorrect way?
> How  can I keep memory usage from exploding like this?
>
> /* Example Below */
>
> package com.example.myproject.client;
>
> import com.google.gwt.core.client.EntryPoint;
> import com.google.gwt.event.dom.client.ClickEvent;
> import com.google.gwt.event.dom.client.ClickHandler;
> import com.google.gwt.user.client.ui.Button;
> import com.google.gwt.user.client.ui.DecoratedTabPanel;
> import com.google.gwt.user.client.ui.DecoratorPanel;
> import com.google.gwt.user.client.ui.HTML;
> import com.google.gwt.user.client.ui.HTMLPanel;
> import com.google.gwt.user.client.ui.HorizontalSplitPanel;
> import com.google.gwt.user.client.ui.RootPanel;
>
> /**
>  * Entry point classes define <code>onModuleLoad()</code>.
>  */
> public class TestApplication01 implements EntryPoint {
>
>         /**
>          * This is the entry point method.
>          */
>         public void onModuleLoad() {
>                 RootPanel.get("container").add( new MainPanel() );
>         }
>
>         private class MainPanel extends DecoratorPanel{
>
>                 private HorizontalSplitPanel hsp;
>                 private HTMLPanel lPanel;
>                 private HTMLPanel rPanel;
>                 private DecoratedTabPanel tabPanel;
>                 int rightPanelCount = 0;
>
>                 public MainPanel(){
>                         hsp = new HorizontalSplitPanel();
>                         hsp.setSplitPosition("25%");
>                         hsp.setSize("800px", "400px");
>                         lPanel = new HTMLPanel("<div id=\"reloadButton\"/>");
>
>                         rPanel = new HTMLPanel("<div id=\"right-panel-contents\"/>");
>                         Button reloadButton = new ReloadButton(this);
>                         reloadButton.setVisible(true);
>                         lPanel.add( reloadButton, "reloadButton" );
>                         hsp.setLeftWidget(lPanel);
>                         hsp.setRightWidget(rPanel);
>                         this.add( hsp );
>                         reloadRight();
>                 }
>
>                 char[] chars = new char[] {' ',' ',' ', ' ', ' ',
> 'a','b','c','d','e','f','g','h','i','j','k','l','m',
>                                                                  'n','o','p','q','r','s','t','u','v','w','x','y','z' };
>
>                 private String getSomeText(int length){
>                         StringBuffer sb = new StringBuffer(length);
>                         for ( int i=0; i<length; ++i ){
>
> sb.append( chars[ (int)Math.round(Math.random()*(chars.length-1)) ]);
>                                 if ( i>0 && i % 60 == 0 )
>                                         sb.append("<br>");
>                         }
>                         return sb.toString();
>                 }
>
>                 protected void reloadRight(){
>                         ++rightPanelCount;
>                         rPanel.clear();
>
>                         tabPanel = new DecoratedTabPanel();
>                         tabPanel.setWidth("400px");
>                         tabPanel.setAnimationEnabled(true);
>
>                         String text = "Load count = "+rightPanelCount;
>
>                         tabPanel.add( new HTML(text+"<br>"+getSomeText((int)
> (Math.random()*500)+500000)), "Tab One");
>                         tabPanel.add( new HTML(text+"<br>"+getSomeText((int)
> (Math.random()*500)+500000)), "Tab Two");
>                         tabPanel.add( new HTML(text+"<br>"+getSomeText((int)
> (Math.random()*500)+500000)), "Tab Three");
>                         tabPanel.add( new HTML(text+"<br>"+getSomeText((int)
> (Math.random()*500)+500000)), "Tab Four");
>                         tabPanel.add( new HTML(text+"<br>"+getSomeText((int)
> (Math.random()*500)+500000)), "Tab Five");
>                         tabPanel.selectTab(0);
>
>                         rPanel.add( tabPanel, "right-panel-contents" );
>                 }
>
>                 private class ReloadButton extends Button{
>
>                         private MainPanel mainPanel;
>
>                         public ReloadButton(MainPanel p){
>                                 super("Reload Right Panel");
>                                 this.mainPanel = p;
>                                 this.addClickHandler(getClickHandler());
>                         }
>
>                         private ClickHandler getClickHandler(){
>                                 return new ClickHandler(){
>
>                                         @Override
>                                         public void onClick(ClickEvent event) {
>                                                 mainPanel.reloadRight();
>                                         }
>                                 };
>                         }
>                 }
>         }
>
>
>
> }

--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To post to this group, send email to google-web-toolkit@googlegroups.com.
To unsubscribe from this group, send email to google-web-toolkit+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.


--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To post to this group, send email to google-web-toolkit@googlegroups.com.
To unsubscribe from this group, send email to google-web-toolkit+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.

No comments:

Post a Comment