question on libnotify usage, specifically relating to freeing up a notification

View: New views
3 Messages — Rating Filter:   Alert me  

question on libnotify usage, specifically relating to freeing up a notification

by Gregory Hosler :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi all,

I've gone thru the devhelp documentation on libnotify, and have been
able to successfully incorporate libnotify into my application.

I am curious as regards to releasing the memory / structures that are
used by a NotifyNotification.

My code is as follows:

        NotifyNotification* my_popup;
        GdkPixbufLoader *my_loader;
        GdkPixbuf *jpg_pixbuf;
        GError *my_error;
        int rv;

        my_popup=notify_notification_new(mytitle, mymsg, NULL,
systray_get_widget());
        if (icon_pixbuf) {
                notify_notification_set_icon_from_pixbuf(my_popup, icon_pixbuf);
                g_object_unref(icon_pixbuf);
        }
        notify_notification_set_timeout(my_popup, timeout);
        my_error = 0;
        rv = notify_notification_show(my_popup, &my_error);


Everything works as expected. The notifications show, they timeout and
disappear. But it seems as though they are never freed/destroyed. When I
run valgrind on my application, I am seeing:

==6969== 10,240 bytes in 5 blocks are still reachable in loss record
13,858 of 13,883
==6969==    at 0x4005622: realloc (vg_replace_malloc.c:306)
==6969==    by 0x26B91A: g_realloc (gmem.c:168)
==6969==    by 0x24601F: g_array_maybe_expand (garray.c:339)
==6969==    by 0x2467D8: g_array_append_vals (garray.c:132)
==6969==    by 0xA9487E: (within /usr/lib/libdbus-glib-1.so.2.1.0)
==6969==    by 0xA937A3: (within /usr/lib/libdbus-glib-1.so.2.1.0)
==6969==    by 0x3B8569: g_value_copy (gvalue.c:119)
==6969==    by 0x3B8B3B: g_value_array_insert (gvaluearray.c:177)
==6969==    by 0x3B8C5D: g_value_array_append (gvaluearray.c:153)
==6969==    by 0xDEF822: notify_notification_set_icon_from_pixbuf
(notification.c:894)

as well as a number of other of instances of "still reachable in loss
record" ...

So my question is: what happens when the notification "times out". Is it
destroyed ?

Same question when you click on teh notification to dismiss it.

Are there any objects that are put into the notification that need to be
"unref"'ed ?

Thank you, and best rgds,

- -Greg

- --
+---------------------------------------------------------------------+

Please also check the log file at "/dev/null" for additional information.
                (from /var/log/Xorg.setup.log)

| Greg Hosler                                   ghosler@...    |
+---------------------------------------------------------------------+
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.7 (GNU/Linux)
Comment: Using GnuPG with Fedora - http://enigmail.mozdev.org

iD8DBQFHafCB404fl/0CV/QRArumAJ9XyGqeDmCBmlXKExV5h/ev138T+ACcDIO3
+llrVQ8mJ1rnDv3czlp/z9g=
=F4Te
-----END PGP SIGNATURE-----
_______________________________________________
galago-devel mailing list
galago-devel@...
http://lists.freedesktop.org/mailman/listinfo/galago-devel

Re: question on libnotify usage, specifically relating to freeing up a notification

by Christian Hammond-3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi.

In your usage below, you want to call g_object_unref on the notification after you've shown it. You won't need it around unless you're dealing with updating it or handling multiple actions, in which case you'd then want to unref when you're finished with it then. I recommend looking at libnotify/tests/ for some examples on this.

Christian


On Dec 19, 2007 8:33 PM, Gregory Hosler <ghosler@...> wrote:
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi all,

I've gone thru the devhelp documentation on libnotify, and have been
able to successfully incorporate libnotify into my application.

I am curious as regards to releasing the memory / structures that are
used by a NotifyNotification.

My code is as follows:

       NotifyNotification* my_popup;
       GdkPixbufLoader *my_loader;
       GdkPixbuf *jpg_pixbuf;
       GError *my_error;
       int rv;

       my_popup=notify_notification_new(mytitle, mymsg, NULL,
systray_get_widget());
       if (icon_pixbuf) {
               notify_notification_set_icon_from_pixbuf(my_popup, icon_pixbuf);
               g_object_unref(icon_pixbuf);
       }
       notify_notification_set_timeout(my_popup, timeout);
       my_error = 0;
       rv = notify_notification_show(my_popup, &my_error);


Everything works as expected. The notifications show, they timeout and
disappear. But it seems as though they are never freed/destroyed. When I
run valgrind on my application, I am seeing:

==6969== 10,240 bytes in 5 blocks are still reachable in loss record
13,858 of 13,883
==6969==    at 0x4005622: realloc (vg_replace_malloc.c:306)
==6969==    by 0x26B91A: g_realloc (gmem.c:168)
==6969==    by 0x24601F: g_array_maybe_expand (garray.c:339)
==6969==    by 0x2467D8: g_array_append_vals ( garray.c:132)
==6969==    by 0xA9487E: (within /usr/lib/libdbus-glib-1.so.2.1.0)
==6969==    by 0xA937A3: (within /usr/lib/libdbus-glib-1.so.2.1.0)
==6969==    by 0x3B8569: g_value_copy (gvalue.c:119)
==6969==    by 0x3B8B3B: g_value_array_insert ( gvaluearray.c:177)
==6969==    by 0x3B8C5D: g_value_array_append (gvaluearray.c:153)
==6969==    by 0xDEF822: notify_notification_set_icon_from_pixbuf
(notification.c:894)

as well as a number of other of instances of "still reachable in loss
record" ...

So my question is: what happens when the notification "times out". Is it
destroyed ?

Same question when you click on teh notification to dismiss it.

Are there any objects that are put into the notification that need to be
"unref"'ed ?

Thank you, and best rgds,

- -Greg

- --
+---------------------------------------------------------------------+

Please also check the log file at "/dev/null" for additional information.
               (from /var/log/Xorg.setup.log)

| Greg Hosler                                   ghosler@...    |
+---------------------------------------------------------------------+
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.7 (GNU/Linux)
Comment: Using GnuPG with Fedora - http://enigmail.mozdev.org

iD8DBQFHafCB404fl/0CV/QRArumAJ9XyGqeDmCBmlXKExV5h/ev138T+ACcDIO3
+llrVQ8mJ1rnDv3czlp/z9g=
=F4Te
-----END PGP SIGNATURE-----
_______________________________________________
galago-devel mailing list
galago-devel@...
http://lists.freedesktop.org/mailman/listinfo/galago-devel



--
Christian Hammond - chipx86@...
VMware, Inc.
_______________________________________________
galago-devel mailing list
galago-devel@...
http://lists.freedesktop.org/mailman/listinfo/galago-devel

Re: question on libnotify usage, specifically relating to freeing up a notification

by Gregory Hosler :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Christian Hammond wrote:
> Hi.
>
> In your usage below, you want to call g_object_unref on the notification
> after you've shown it. You won't need it around unless you're dealing with
> updating it or handling multiple actions, in which case you'd then want to
> unref when you're finished with it then. I recommend looking at
> libnotify/tests/ for some examples on this.
>
> Christian


Thanks a lot Christian!

best rgds,

- -Greg

>
> On Dec 19, 2007 8:33 PM, Gregory Hosler <ghosler@...> wrote:
>
> Hi all,
>
> I've gone thru the devhelp documentation on libnotify, and have been
> able to successfully incorporate libnotify into my application.
>
> I am curious as regards to releasing the memory / structures that are
> used by a NotifyNotification.
>
> My code is as follows:
>
>        NotifyNotification* my_popup;
>        GdkPixbufLoader *my_loader;
>        GdkPixbuf *jpg_pixbuf;
>        GError *my_error;
>        int rv;
>
>        my_popup=notify_notification_new(mytitle, mymsg, NULL,
> systray_get_widget());
>        if (icon_pixbuf) {
>                notify_notification_set_icon_from_pixbuf(my_popup,
> icon_pixbuf);
>                g_object_unref(icon_pixbuf);
>        }
>        notify_notification_set_timeout(my_popup, timeout);
>        my_error = 0;
>        rv = notify_notification_show(my_popup, &my_error);
>
>
> Everything works as expected. The notifications show, they timeout and
> disappear. But it seems as though they are never freed/destroyed. When I
> run valgrind on my application, I am seeing:
>
> ==6969== 10,240 bytes in 5 blocks are still reachable in loss record
> 13,858 of 13,883
> ==6969==    at 0x4005622: realloc (vg_replace_malloc.c:306)
> ==6969==    by 0x26B91A: g_realloc (gmem.c:168)
> ==6969==    by 0x24601F: g_array_maybe_expand (garray.c:339)
> ==6969==    by 0x2467D8: g_array_append_vals (garray.c:132)
> ==6969==    by 0xA9487E: (within /usr/lib/libdbus-glib-1.so.2.1.0)
> ==6969==    by 0xA937A3: (within /usr/lib/libdbus-glib-1.so.2.1.0)
> ==6969==    by 0x3B8569: g_value_copy (gvalue.c:119)
> ==6969==    by 0x3B8B3B: g_value_array_insert (gvaluearray.c:177)
> ==6969==    by 0x3B8C5D: g_value_array_append (gvaluearray.c:153)
> ==6969==    by 0xDEF822: notify_notification_set_icon_from_pixbuf
> (notification.c:894)
>
> as well as a number of other of instances of "still reachable in loss
> record" ...
>
> So my question is: what happens when the notification "times out". Is it
> destroyed ?
>
> Same question when you click on teh notification to dismiss it.
>
> Are there any objects that are put into the notification that need to be
> "unref"'ed ?
>
> Thank you, and best rgds,
>
> -Greg
>
_______________________________________________
galago-devel mailing list
galago-devel@...
http://lists.freedesktop.org/mailman/listinfo/galago-devel
>>

- --
+---------------------------------------------------------------------+

Please also check the log file at "/dev/null" for additional information.
                (from /var/log/Xorg.setup.log)

| Greg Hosler                                   ghosler@...    |
+---------------------------------------------------------------------+
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.7 (GNU/Linux)
Comment: Using GnuPG with Fedora - http://enigmail.mozdev.org

iD8DBQFHa445404fl/0CV/QRAj26AJ0fZ/omR4X4eRJWMg/8stTdoEpkLwCdE3+A
SsgfCyq2HyloKkO097hG2kg=
=1vxv
-----END PGP SIGNATURE-----
_______________________________________________
galago-devel mailing list
galago-devel@...
http://lists.freedesktop.org/mailman/listinfo/galago-devel