Release RAM again after closing the file?

Have some feature requests, feedback, cool stuff to share, or want to know where FreeCAD is going? This is the place.
Forum rules
Be nice to others! Read the FreeCAD code of conduct!
User avatar
thomas-neemann
Veteran
Posts: 11958
Joined: Wed Jan 22, 2020 6:03 pm
Location: Osnabrück DE 🇩🇪
Contact:

Release RAM again after closing the file?

Post by thomas-neemann »

does it take a lot of programming to free up RAM after closing the file?

here is an example

with the file open
1.png
1.png (26.36 KiB) Viewed 1327 times



after closing the file
2.png
2.png (113 KiB) Viewed 1327 times



after restart
3.png
3.png (9.49 KiB) Viewed 1327 times
Gruß Dipl.-Ing. (FH) Thomas Neemann

https://www.youtube.com/@thomasneemann5 ... ry=freecad
openBrain
Veteran
Posts: 9041
Joined: Fri Nov 09, 2018 5:38 pm
Contact:

Re: Release RAM again after closing the file?

Post by openBrain »

Your analysis basically makes no sense.
RAM is not only (only few) taken by documents, but also by workbenches and libraries loading. These latter ones aren't freed on document close (which is totally correct).
User avatar
thomas-neemann
Veteran
Posts: 11958
Joined: Wed Jan 22, 2020 6:03 pm
Location: Osnabrück DE 🇩🇪
Contact:

Re: Release RAM again after closing the file?

Post by thomas-neemann »

openBrain wrote: Thu Dec 09, 2021 11:06 am
I started freecad for this test and then immediately loaded the (large) file without loading a workbech
Gruß Dipl.-Ing. (FH) Thomas Neemann

https://www.youtube.com/@thomasneemann5 ... ry=freecad
openBrain
Veteran
Posts: 9041
Joined: Fri Nov 09, 2018 5:38 pm
Contact:

Re: Release RAM again after closing the file?

Post by openBrain »

thomas-neemann wrote: Thu Dec 09, 2021 11:13 am I started freecad for this test and then immediately loaded the (large) file without loading a workbech
Depending on object types inside the document, tons of libs can be loaded just to compute it at opening time. ;)
User avatar
thomas-neemann
Veteran
Posts: 11958
Joined: Wed Jan 22, 2020 6:03 pm
Location: Osnabrück DE 🇩🇪
Contact:

Re: Release RAM again after closing the file?

Post by thomas-neemann »

openBrain wrote: Thu Dec 09, 2021 11:45 am
then you could recommend restarting freecad after closing a file before opening a new one?
Gruß Dipl.-Ing. (FH) Thomas Neemann

https://www.youtube.com/@thomasneemann5 ... ry=freecad
openBrain
Veteran
Posts: 9041
Joined: Fri Nov 09, 2018 5:38 pm
Contact:

Re: Release RAM again after closing the file?

Post by openBrain »

thomas-neemann wrote: Thu Dec 09, 2021 11:52 am then you could recommend restarting freecad after closing a file before opening a new one?
Nope. It doesn't change anything roughly.
If you want to have an idea, do a copy of your sample doc. From a fresh FC start, open the original one, look at the RAM consumption, then open the copy, and look at the extra RAM amount. This is roughly how much is "consumed" by the doc. Close the copy and look if RAM is freed. ;)
User avatar
thomas-neemann
Veteran
Posts: 11958
Joined: Wed Jan 22, 2020 6:03 pm
Location: Osnabrück DE 🇩🇪
Contact:

Re: Release RAM again after closing the file?

Post by thomas-neemann »

openBrain wrote: Thu Dec 09, 2021 12:44 pm ... From a fresh FC start, open the original one, look at the RAM consumption, then open the copy, and look at the extra RAM amount. ...
I've done that now. according to my measurements on a linux system i used 2.3 gb ram when opening the copy. after closing the copy, only 0.006 gb was released. so the question remains whether you can reprogram it with low of effort, or restart freecad after closing large files?

edit

OS: Ubuntu 20.04.1 LTS (XFCE/xubuntu)
Word size of FreeCAD: 64-bit
Version: 0.20.26554 (Git) AppImage
Build type: Release
Branch: (HEAD detached at 817c14b)
Hash: 817c14b16af681b06aec7d8c79f744c7a88fa3c3
Python version: 3.9.7
Qt version: 5.12.9
Coin version: 4.0.0
OCC version: 7.5.3
Locale: German/Germany (de_DE)
Gruß Dipl.-Ing. (FH) Thomas Neemann

https://www.youtube.com/@thomasneemann5 ... ry=freecad
openBrain
Veteran
Posts: 9041
Joined: Fri Nov 09, 2018 5:38 pm
Contact:

Re: Release RAM again after closing the file?

Post by openBrain »

thomas-neemann wrote: Thu Dec 09, 2021 2:34 pm i used 2.3 gb ram when opening the copy.
Could you give all numbers please (sorry to insist, but need a good understanding) :
* RAM occupied just after FC start
* RAM occupied just after opening the sample doc
* RAM occupied just after opening the copy of the doc
* RAM occupied just after closing the copy of the doc
Will do some tests on my side.

Notice that it is hard to diagnose an actual "problem". For example, the OS when you open a file can copy it into RAM, then when you close it choose to keep it in RAM in case you'll need it again soon. It doesn't need that the RAM isn't freed by the program, just the OS has a good RAM strategy. :)
User avatar
thomas-neemann
Veteran
Posts: 11958
Joined: Wed Jan 22, 2020 6:03 pm
Location: Osnabrück DE 🇩🇪
Contact:

Re: Release RAM again after closing the file?

Post by thomas-neemann »

openBrain wrote: Thu Dec 09, 2021 2:48 pm
i'm doing it tonight
Gruß Dipl.-Ing. (FH) Thomas Neemann

https://www.youtube.com/@thomasneemann5 ... ry=freecad
openBrain
Veteran
Posts: 9041
Joined: Fri Nov 09, 2018 5:38 pm
Contact:

Re: Release RAM again after closing the file?

Post by openBrain »

thomas-neemann wrote: Thu Dec 09, 2021 2:50 pm i'm doing it tonight
OK, I tried to open/close 20-30 times the same document, and RAM values are almost steady, so at least there doesn't seem to be a significant leak.

After 200 repeated open/close, it's 4 MB increase in RAM, so looks acceptable to me.
Post Reply