Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
python-fu : close xcf/clear memory
#1
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?
Reply
#2
If you're doing a gimp-image-new, then a gimp-image-delete should clean up
Reply
#3
Or in python, gimp.delete(image)
Reply
#4
Thanks, I'll try it out
Reply
#5
Forgot to give my definite answer:
gimp.delete(image) worked, no more filled memory. Thanks!
Reply
#6
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?
Reply
#7
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 ?
Reply
#8
(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?
Reply
#9
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 (•ٹ•)
Reply


Forum Jump: