Gimp-Forum.net
python-fu : close xcf/clear memory - Printable Version

+- Gimp-Forum.net (https://www.gimp-forum.net)
+-- Forum: GIMP (https://www.gimp-forum.net/Forum-GIMP)
+--- Forum: Extending the GIMP (https://www.gimp-forum.net/Forum-Extending-the-GIMP)
+---- Forum: Scripting questions (https://www.gimp-forum.net/Forum-Scripting-questions)
+---- Thread: python-fu : close xcf/clear memory (/Thread-python-fu-close-xcf-clear-memory)



python-fu : close xcf/clear memory - ChameleonScales - 09-02-2020

I made a script that creates xcfs, does a few things and saves them. Problem is, it gradually fills up my memory when I execute it on many files.

The last command of the loop is pdb.gimp_xcf_save. So I wonder if I need to add a command to close the xcf of somehow clear the memory, but I didn't find such a thing.
Any idea?


RE: python-fu : close xcf/clear memory - Kevin - 09-02-2020

If you're doing a gimp-image-new, then a gimp-image-delete should clean up


RE: python-fu : close xcf/clear memory - Ofnuts - 09-02-2020

Or in python, gimp.delete(image)


RE: python-fu : close xcf/clear memory - ChameleonScales - 09-03-2020

Thanks, I'll try it out


RE: python-fu : close xcf/clear memory - ChameleonScales - 02-09-2021

Forgot to give my definite answer:
gimp.delete(image) worked, no more filled memory. Thanks!


RE: python-fu : close xcf/clear memory - ChameleonScales - 03-08-2021

I again have a memory filling issue even using gimp.delete(image). I checked for proper position of the command in my loop by inserting a print(image) right before and it's well positioned.
It seems Gimp keeps non inserted layers even after deleting the image, which surprises me because the command to load them needs an image in the arguments: pdb.gimp_file_load_layer(image, filename) so I assume they are still assigned to an image and should be flushed with it, but according to my test that's not the case.
Is there a way to list all the non inserted layers so I can delete them all?


RE: python-fu : close xcf/clear memory - ChameleonScales - 03-08-2021

Ok so I confirm that non inserted layers are kept and I could prevent having any remaining ones before the image gets deleted, so no need to list them (still curious to know if that's possible though).

I however get a segmentation fault and crash when trying to print a non inserted layer after deleting it with pdb.gimp_item_delete. Is this expected or should I make a bug report ?


RE: python-fu : close xcf/clear memory - Ofnuts - 03-08-2021

(03-08-2021, 04:16 PM)ChameleonScales Wrote: I however get a segmentation fault and crash when trying to print a non inserted layer after deleting it with pdb.gimp_item_delete. Is this expected or should I make a bug report ?

Seems expected to me. What do you do with the layers if you don't add them to an image?


RE: python-fu : close xcf/clear memory - ChameleonScales - 03-09-2021

Quote:What do you do with the layers if you don't add them to an image?


Bad code is what I do. But I fixed it (•ٹ•)