1

I am trying to figure out why my GIMP plugin uses more and more RAM during it's execution. I wrote a simple test plugin to check if deleting images through pdb.gimp_image_delete works as intended:

image_id = pdb.gimp_image_new(500, 500, RGB)
while True:
    duplicate = pdb.gimp_image_duplicate(image_id)
    pdb.gimp_image_delete(image_id)
    image_id = duplicate
    print pdb.gimp_image_list()

Image list looks fine - in every iteration pdb.gimp_image_list shows that there is only one image, but RAM usage grows rapidly. It's close 1GB after 1 min of execution! It looks like gimp_image_delete leaves image in memory somehow or something else is causing this. Any ideas how to solve this? I thought that it may be fault of gimp_image_duplicate, but replacing duplicate = pdb.gimp_image_duplicate(image_id) with image_id = pdb.gimp_image_new(500, 500, RGB) gives the same effect. I also tried gimp.delete function.

  • 1
    First question: is the memory used by the Gimp process or the Python process? – xenoid Dec 03 '17 at 18:23
  • Somehow same constatation here, creating 10K 2000x2000 images ends up eating 100MB (but this seems to increase non-linearly...). Good candidate for http://bugzilla.gnome.org (but what kind of script needs to create 10K images?) – xenoid Dec 03 '17 at 19:02
  • @xenoid It's Gimp process. And about the need to create so many images - I'm writing a script which tries to draw the input image. So every time it draws something that doesn't make the output better, it has to perform undo action. I didn't find any convenient way to do undo using gimpfu, so I have to create duplicate of the image before every drawing action and then delete the one that is "worse". In that way it can create thousands of images and RAM usage usually reaches about 1GB after ~1 hour of execution. – Martyna Chruściel Dec 04 '17 at 16:39
  • What happens if you delete/recreate layers instead? And what are you using in Gimp? There are more efficient image processing libraries out there. – xenoid Dec 04 '17 at 17:03
  • @xenoid It's the same with layers. `gimp_image_remove_layer` removes it from the list returned by `gimp_image_get_layers` but RAM seems to not be affected at all and usage grows continuously. I'm using Gimp, because it's the whole point of my university project - the idea was to draw images using tools imitating human behavior instead of creating shapes "computer way", pixel by pixel. – Martyna Chruściel Dec 11 '17 at 20:33
  • When you play intensively with layers, you create a work image, and disable its "undo stack" (`pdb.gimp_image_undo_disable(image)`). Otherwise your layers can still be kept in the undo stack. When done you copy the result layer(s) to the initial image. – xenoid Dec 11 '17 at 21:47
  • It is somewhat common for applications to not release memory unless something else requires it. So for these tests to become meaningful, you should check whether GIMP is hogging the memory even if another application is requesting it. – Michael Schumacher Dec 15 '17 at 12:54

0 Answers0