--gapplication-service and memory management

Hi!

In EasyEffects(and PulseEffects) I use --gappplication-service to keep the application running in background once its window is closed. It works but when the window is closed I never see a decrease in the memory used by the application(measured in gnome system monitor). It does not seem that there is a leak. If I close and open the window multiple times the memory usage is essentially the same within some small fluctuation. It is almost like gtk is caching something related to the widgets. Is there something special that has to be done when using --gapplication-service or is this the way gtk3/gtk4 handles memory?

In case anyone wants to see this is how I create and destroy the window https://github.com/wwmm/easyeffects/blob/f76cf2bee9032c4759a3db6e13dfffac90fea9d3/src/application.cpp#L276

I can’t say for certain what is happening without profiling, but usual behavior of glibc malloc is to avoid releasing memory back to the OS unless the allocation is large. This is tunable by the application, see here, here, here. Also you could try that with G_SLICE=always-malloc to see if that changes anything.

Setting G_SLICE=always-malloc does not make any difference. After running “easyeffects --gapplication-service” the process memory usage is around 71 MB. And after opening the window it jumps to 165 MB and within a very small fluctuation it stays in this value if all we do is closing and opening the window.

As it does not seem to be leaking memory when closing and opening the window I think there is nothing to be concerned about. It is just weird. Usually when we delete things the memory used by the process decreases. But in this case it seems that under the hoods gtk is keeping the allocations it did before.

Sorry I should have been more clear. You will also need to tune some of the glibc malloc parameters in addition to that variable. If that fails then somebody will need to profile the app.

I see. But it does not look like something I can do from the application side. It seems too low level for that. Unless I misunderstood something the code passing options to mallopt is deep within gtk.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.