Are there an issues with Dolphin not releasing memory after being closed?
I’ve been running SQLite queries from the CLI using the .read method and some Tcl scripts using tclsh.
I noticed that the memory usage appeared higher than expected and found that there were 32 Dolphin processes from 25 MiB to 50 MiB each. After closing Dolphin, the processes remain. I closed System Monitor and re-opened it, and it then showed Dolphin in Applications using 1.6 GiB but I closed it before that. I also closed Konsole (SQLite and Tcl).
I’ve been working with two desktop views and had Dolphin open in each view at some times.
Is this expected or could I be doing something wrong to cause it? Thank you.
I forgot to write that I also have Kate open in two desktops. When I try to close Dolphin from within System Monitor, it warns that unsaved work could be lost. What work is it referring to? If there is an issue in Dolphin, but I save my work in Kate, it will still be saved; will it not?
From a developer point of view - and I have dealt with a fair share of programming related memory issues over the years - a memory build-up can be caused in several ways.
On Linux file system cache contributes to memory usage. This usage will be released ad-hoc when it is no longer needed.
sqlite is a database - most often consisting of a single file - so when you query the database the file will be cached.
Another cause is how the programmer deals with the objects created to query the database. Many modern languages like rust, python and c# has automatic garbage collection, yet is is still good practice to have a using or with declaration to have the language clean up automagically.
When an sqlite object is created to communicate with the database, then you open the connection, use another object to query the database, reading the data into a third object to process the data. If the record set is not released and connection is not closed you may leave dangling objects. If you start enough instances - it may become a problem.
I started my developer merits by building applications for DOS using Quick Basic 4, later it was Visual Basic on Windows 3.11 - and back then, releasing memory was important, one learned to close database connections and record sets to avoid crashing the system.
I apologize for not learning the proper terminology and am referring to the rectangular icons (near the big K on my screen) that toggle between Desktop 1 and 2. Just one login.
I just closed it from within System Monitor and it appears to have released the memory and I see not more Dolphin processes.
Just out of curiosity, what does Dolphin have to do with executing the SQL queries? They are edited in Kate, run in Konsole through SQLite3 or a Tcl script that requires SQLite, and they change a SQLite file on disk (sometimes using an in-memory database to help). I assumed Dolphin was just an application to help locate and organize files, but not execute them. But I don’t know how any of that works. I mean SQLite and Tcl have to handle releasing memory that they allocate, but, if they failed to, the OS should free it when they or Konsole are closed. Does Dolphin allocate memory?
Thank you. No,I do no use the built in Konsole in Dolphin.
But I also run a Tcl application from Konsole such that I can write data to stdout while using the application to debug and monitor. I keep terminating the program, edit some part of it, and start it again from within the same Konsole. And then check the database tables in another Konsole instance to see how the Tcl application is changing the data.
But, if I make a mistake in my program that results in not releasing memory, once I close Konsole, shouldn’t the OS release it all?
The OS has no way of knowing if the object is garbage or not…
File system cache is transparent - and handled by the OS - your sqlite objects is handled by your application.
//EDIT::
This could leave objects in memory - if you do not catch the termination signal in code and from within the function - explicitly clean all instantiated objects.
On my system a single Dolphin instance occupies around 65 MB memory.
Using the builtin konsole (F4) adds only 1MB without adding a konsole instance to the process listing.
When using the built-in terminal of dolphin, closing the terminal or closing dolphin will not stop the shell started that way. One has to stop it by typing exit or hitting CtrlD at the prompt.
Okay, thank you. Let’s suppose it is true that closing my application somehow results in memory not being released. Why would that result in an additional Dolphin process or involve memory usage in Dolphin? Should it not be memory used by Konsole since the application is started using something like tclsh start.tcl on the command line?
I’ve been building like this for the past three years and never saw this before in Dolphin; but I could have made a code change that just started to cause it, too. I suppose if I do nothing in Dolphin while working on the application and no new Dolphin processes appear in System Monitor, then I can rule out that they were the result of my application being abruptly closed.
The only other thing I can think of is that I’ve been backing up a 15 GiB SQLite file to USB the past several nights. It runs to completion without issue (maybe 3-5 minutes duration) but I have not checked System Monitor immediately thereafter. I will try that again later today just as I usually do it. I really don’t need to do it that way and could attach the database on the USB to the same Konsole connection and write only the tables that have changed. But it’s easier to not worry about it and just write the file. Thanks.
I just remembered something else also. I have Dolphin open in each Desktop to different folder locations. Insert the USB, and a new Dolphin window is opened but not an empty one, a duplicate of the existing one with an added tab for the USB drive or it remembers what was open in Dolphin the last time the drive was inserted. After the writing to USB completes, I generally close the Dolphin tab that has the USB path open and close that Dolphin window before removing the USB drive; but sometimes I forget and remove the drive before closing the tab and/or window. I remove it correctly and only after the system states it is safe to remove it but I leave that Dolphin window open until after the drive is removed. I’ll try testing that later also, especially since it is directly related to Dolphin “work.”
This might be easily reproducible
With two Desktop windows open and Dolphin opened in Desktop 1, if I open a new Dolphin instance in Desktop 2 a new process is created; but, when the Dolphin instance is closed, the process remains. If that is repeated, several processes remain even when Dolphin is not open in Desktop 2 and even if close it in Desktop 1 also; and System Monitor shows Dolphin open with several sessions worth of memory being used. Sometimes Dolphin does not show up under Applications in the Overview tab of System Monitor but does in the Applications tab. I closed System Monitor and re-opened it (just in case the process list was not being refreshed) and Dolphin still appears and with a large memory usage. I tried it on my desktop and laptop with the same results.
Should those processes end when each instance of Dolphin is closed or at least when all instances have been closed in both Desktops?
Once in this state, Dolphin can be closed from within System Monitor and all the processes then end.
Does anyone else see this occurring or, perhaps, I have somethng set up wrong?
This is not an operating system issue and dolphin is affected because you use dolphin to launch your application.
This behaviour indicates that processes started is originating from dolphin.
This can have any number of causes - most likely it is an application executed from the dolphin file pane.
As I suggested above - the application does not cleanup properly - e.g. by intercepting a termination signal - parts of the application started by remains in memory - and since the application was started by dolphin using the file pane - the process appear to be dolphin itself.
The behaviour is a typical memory leak situation created by a faulty application but you see it as a dolphin issue.
This is not the case - dolphin is merely a victim here - the real culprit is the behaviour of you application and the fact that you deliberately terminate your application without doing proper cleanup.
I reboot the system. I open no applications but Dolphin and System Monitor, and do not open any files. Just open and close Dolphin and watch System monitor and the Dolphin processes increase as does memory usage. Those proceses do not end when Dolphin is closed.
My application can have nothing to do with the above scenario.
If this does not take place on your system, can you tell me how to figure out why it happens on mine?
Thank you. I am using stable branch and all my configuration settings appear to be the defaults. I have it recall the open tabs at start but I tried switching that, and it still keeps the process after closing.
When you wrote “…because you use dolphin to launch your application” and I had already written that I open it from Konsole using tclsh start.tcl, do you mean that Konsole and Dolphin are “connected” even if Konsole is not opened through Dolphin?
I ask because I try to follow memory used by the application but it’s a bit hard to follow in System Monitor.
No that is not what I meant but what I meant have no meaning now.
To deduce whether it is a memory leak with dolphin - which may have been fixed with 25.04.2 - I suggest you try switching branch - run a full system sync and restart your system.
Then verify your observation - other than that - I have nothing more to offer.
As for system monitor - try using the application → Show Details Sidebar - this will show the processes owned all processes for the selected application.
Likewise processes can be filtered to show user process only - could be the default.