So it looks like there is some memory issues. Are they leaks, I don’t know.
But the aim of my question was more to get a feedback if there was something wrong with my code as I am not familiar with glib.
And my main worry is that a similar code is called from a process which never ends, so after a while, the oom-killer is killing my process. And now, I am trying to find an understanding of what is happening and a fix (if any).
That’s a bit hard to say. The code you pasted is obviously not the production code (and I’m not volunteering to review your production code). In general, though, the main things you should consider are:
Async code in GLib generally assumes that a main loop is running. While GDBus does have a worker thread for communicating with the D-Bus socket in the background, callbacks are sent to the main thread and if you’re not running the global default main loop then they’ll probably queue up indefinitely.
Calling D-Bus methods synchronously is generally a bad idea because they can take many seconds to give a reply; your application will be blocked from handling other events for that time unless you make the D-Bus call asynchronously.
Writing asynchronous code is something you have to do from the beginning; unfortunately C doesn’t have the syntax to allow you to easily convert synchronous code to asynchronous code at a later date.
In the context of our application, sync calls are easier to implement and we don’t mind waiting for the answers. I am going to investigate a little bit on this issue. But if I can’t find any improvement, I will switch to async calls.