weather applet leaks memory on every update

Bug #275512 reported by moonbeam
2
Affects Status Importance Assigned to Milestone
Awn Extras
Fix Released
Medium
onox

Bug Description

It appears the weather applet leaks memory on every update.

After running for several days...

mapped: 159988K writeable/private: 106588K shared: 1072K

Use context menu to refresh.

mapped: 160392K writeable/private: 106992K shared: 1072K

Use context menu to refresh.

mapped: 160796K writeable/private: 107396K shared: 1072K

Related branches

moonbeam (rcryderman)
Changed in awn-extras:
assignee: nobody → michael
Revision history for this message
Michael Rooney (mrooney) wrote :

Thanks for the report and easy instructions to duplicate, I will check this out. Have you looked at it moonbeam and have any ideas or hints?

Revision history for this message
onox (onox) wrote :

I can reproduce it on my system. Everytime I click "Refresh" in the context menu, RES in htop increases with about 400. An instance of weather that was running for a while (+- 20 hours) used 55M instead of 31M originally.

Changed in awn-extras:
status: New → Confirmed
Revision history for this message
Michael Rooney (mrooney) wrote : Re: [Bug 275512] Re: weather applet leaks memory on every update

Yes, this is because on each refresh a new dialog is created instead of
clearing and reusing the current one, I think. I was originally told this
would be fine and awnlib would handle it but, I might be holding on to a
reference somewhere (I don't think) or awnlib is, or it could just be how
pygtk works. For example when I do
'dlog = self.applet.dialog.new("secondary")', and a secondary dialog already
exists, is awnlib cleaning that up?

Could either of you try commenting out line 177 of weather.py where it
refreshes the forecast, and see if the leak goes away? I am not sure if it
is the forecast, the map, or both.

Revision history for this message
onox (onox) wrote :

awnlib does keep a reference (in a dictionary), but the key ("secondary") is
mapped to the new instance of awn.AppletDialog when you call
self.applet.dialog.new("secondary"), so I guess python should gc it after a
while.

It seems the leak is only reduced when I comment both onRefreshForecast and
onRefreshMap. It's not really a good practice to recreate the dialog
everytime. Just create the dialog once and then update the content inside it
(I don't know whether you use an image or drawing area)

On Fri, Feb 20, 2009 at 7:43 PM, Michael Rooney <email address hidden> wrote:

> Yes, this is because on each refresh a new dialog is created instead of
> clearing and reusing the current one, I think. I was originally told this
> would be fine and awnlib would handle it but, I might be holding on to a
> reference somewhere (I don't think) or awnlib is, or it could just be how
> pygtk works. For example when I do
> 'dlog = self.applet.dialog.new("secondary")', and a secondary dialog
> already
> exists, is awnlib cleaning that up?
>
> Could either of you try commenting out line 177 of weather.py where it
> refreshes the forecast, and see if the leak goes away? I am not sure if it
> is the forecast, the map, or both.
>
> --
> weather applet leaks memory on every update
> https://bugs.launchpad.net/bugs/275512
> You received this bug notification because you are subscribed to Awn
> Extras.
>
> Status in Awn Extras: Confirmed
>
> Bug description:
> It appears the weather applet leaks memory on every update.
>
> After running for several days...
>
> mapped: 159988K writeable/private: 106588K shared: 1072K
>
> Use context menu to refresh.
>
> mapped: 160392K writeable/private: 106992K shared: 1072K
>
> Use context menu to refresh.
>
> mapped: 160796K writeable/private: 107396K shared: 1072K
>

Revision history for this message
Michael Rooney (mrooney) wrote :

>
>
> It seems the leak is only reduced when I comment both onRefreshForecast and
> onRefreshMap.

Does this mean that onRefreshMap is the sole source of the leak, of only
commenting onRefreshForecast doesn't reduce it? If you just comment the map
refresh does it go away?

> It's not really a good practice to recreate the dialog
> everytime. Just create the dialog once and then update the content inside
> it
> (I don't know whether you use an image or drawing area)

Yeah, that's what is blocking this for me, I am a gtk neophyte and have no
idea how to re-use the same one. The forecast dialog and map dialogs both
just contain a gtk.Image I believe. The problem with re-using the dialog for
the forecast is that you can change the dialog type at run-time
(curved/transparent or normal), so it just creates it fresh one each time. I
guess it would need to cache the last dialog type and see if it has changed
and only recreate it then.

Revision history for this message
onox (onox) wrote :

gtk.Image has several set_from_*() methods, you could probably use one those.

Changed in awn-extras:
importance: Undecided → Medium
Revision history for this message
Michael Rooney (mrooney) wrote :

Okay thanks, that will probably work. Could you let me know about my
previous question, of if it is only the map that is leaking or both? Ie does
anything change if you comment out the map refresh instead of the forecast?
If so then I can just make it reset the image like you mention.

Revision history for this message
onox (onox) wrote :

If I comment out the map refresh, it leaks around 400, if I just comment out the forecast refresh then 300 / 400 too. Btw, when I refresh, the applet seems unresponsive and I cannot the current data (forecast or map) for several seconds.

onox (onox)
Changed in awn-extras:
assignee: mrooney → onox
onox (onox)
Changed in awn-extras:
milestone: none → 0.4.0
onox (onox)
Changed in awn-extras:
status: Confirmed → In Progress
Revision history for this message
onox (onox) wrote :

Fixed in rewrite.

Changed in awn-extras:
status: In Progress → Fix Committed
Mark Lee (malept)
Changed in awn-extras:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.