On Mon, Jul 4, 2011 at 6:00 PM, Alberto Rugnone
<arugnonechemi...@gmail.com>wrote:

> Hello everybody,
> In my office we are experiencing a very bad problem of memory leak. We
> are developing an application with GWT based on MVP architecture.
> Each widget is a MVP and each MVP is based on a own class named
> DefaultWidgetPresenter.  The applicaion has to create periodically new
> Presenters (subclass of the first) and deletes periodically olders.
> Anyway application memory grows up. Profiling the application with
> developer tools provided by Chrome or Safari we registered that
> Presenter keeps their number increasing slowly and
> DefaultWidgetPresenter still growing up rapidly, and we don't
> understand why? We checked if we deleted correctly the presenter and
> sincerely I can't say "yes" because our probably no deep understanding
> of GWT technology.
> This is the application procedure in a nutshell
> 1) Application create a Presenter dynamically
> 2) Then it put its displays in a panel
> 3) Then after a certain time it creates a new Presenter
> 4) It clears the panel then add the new display.
> ... and so on
>
> I expected old presenters are garbage collected in some way. In
> addition I don't understand why we have difference between number of
> Presenters instances  and parents classes instance. I took
> measurements also from chrome's task manager but I can't understand
> the relation between profiling and that. In fact when I use profiling
> the memory grows in  a strange way probably because profiling
> instrument the memory in some way.
>
> There is some one that can help us and explain those behaviours? I am
> wondering also if a key to understand the problem could be understand
> how GWT implements inheritage and garbage collecting? ?
>
> Thank you in advance for any help, this problem is very important.
>
> Regards
> Alberto
>
> --
> 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+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/google-web-toolkit?hl=en.
>
> Hi Alberto,

Being an absolute novice in Java development but having spend many years
supporting Java based applications and working with many other programming
languages I would say there is a relatively simple reason for this behavior.

Usually the garbage collector will kill what ever is considered old enough
(there are various stages in the objects life cycle but who cares right
unused objects will die in the end). What you are doing to kill of the
object in your code is not working as you expect it to. As long as there is
a single reference to the object the garbage collector will see this as a
object that's in use and thus will not remove it.

So what I understand form your post you are simply deleting the presenter
from the panel. This works well for static things like a button or an image
but as soon as you are talking a widget that is displaying data the data
that you are displaying will still be updated in that widget as all you did
is remove the widget from the display part of your program the code that is
updating the widget will happily continue to work. I would say you will need
to build a destroy method for your presenter that will remove all links to
the data to be displayed. If you call this after you delete the presenter
you should see the garbage collector clean it up nicely.

Now as I said before I am a complete novice in Java/GWT so I cannot make any
promises about the sanity of my comments but from what I know from other
languages and from supporting Java based systems for many years; the usual
reason a garbage collector misses an object is because the developer forgot
to remove all references to that object. ;-)

Regards,

Rob

-- 
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+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-web-toolkit?hl=en.

Reply via email to