← Back to team overview

dx-packages team mailing list archive

[Bug 725435] Re: notify-osd a memory hog (memory leak?)

 

I think I have the solution.

First an explanation of the above quitting logic: The "bubble IDs" count
upwards from 1, one for each notification bubble shown. When the bubble
ID reaches FORCED_SHUTDOWN_THRESHOLD = 500, then _arm_forced_quit() is
called, which quits the process using gtk_main_quit() and thus
terminates notify-osd, and it is restarted automatically (I think by
DBUS) when the next notification comes in.

So the first bubble ID is 1, the second 2, and so on.
You can verify that e.g. by inserting

        printf("bubble ID %u\n", bubble_get_id (bubble));

But this is only the case if you wait between your `notify-send mytext` invocations until the current bubble has faded out and is no longer shown.
If you call `notify-send mytext` while the previous notification is still being displayed then bubble ID is actually 0.
(This is because the variable `bubble` is NULL in that case, and bubble_get_id(NULL) returns 0.)
But the bubble ID generation counter is still incremented nevertheless.
So if your generated bubble IDs are 1, 2, and then 0, the next bubble ID generated will be 4.

You can generate this situation e.g. this way (note that the default
notification timeout is 10 seconds, so I sleep 11 seconds):

    notify-send test && sleep 11 && notify-send test && notify-send test
&& sleep 11 && notify-send test

So when you send notifications in quick succession, their bubble IDs are
skipped.

Now, if you send them in quick succession around the 500th notification,
then the check

  if (bubble_get_id (bubble) == FORCED_SHUTDOWN_THRESHOLD)

will never trigger (e.g. because the bubble IDs will be 499, 0, and
501).

Then the forced shutdown will never happen, and notify-osd will leak
memory forever instead of being restarted every 500th notification.

The fix is to use

  if (bubble_get_id (bubble) >= FORCED_SHUTDOWN_THRESHOLD)

instead.

-- 
You received this bug notification because you are a member of DX
Packages, which is subscribed to notify-osd in Ubuntu.
Matching subscriptions: dx-packages
https://bugs.launchpad.net/bugs/725435

Title:
  notify-osd a memory hog (memory leak?)

Status in notify-osd package in Ubuntu:
  Confirmed

Bug description:
  Binary package hint: notify-osd

  Noticed this today on my lucid box in top:
  2647 myaccount  20   0 1196m 595m 3528 S    0 29.7   1:09.68 notify-osd

  I don't think a simple notifcation daemon should suck up more than a
  Gig of memory of which half is real memory.  It's the first time I
  noticed this.  I don't have too much information at this point.

  $ dpkg -l notify-osd*
  Desired=Unknown/Install/Remove/Purge/Hold
  | Status=Not/Inst/Cfg-files/Unpacked/Failed-cfg/Half-inst/trig-aWait/Trig-pend
  |/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
  ||/ Name                                          Version                                       Description
  +++-=============================================-=============================================-==========================================================================================================
  ii  notify-osd                                    0.9.29-0ubuntu2                               daemon that displays passive pop-up notifications
  ii  notify-osd-icons                              0.6                                           Notify-OSD icons

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/notify-osd/+bug/725435/+subscriptions