After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 86586 - Script-fu leaks memory.
Script-fu leaks memory.
Status: VERIFIED FIXED
Product: GIMP
Classification: Other
Component: Script-Fu
1.x
Other Linux
: Normal normal
: ---
Assigned To: GIMP Bugs
GIMP Bugs
: 108966 (view as bug list)
Depends on:
Blocks: 101604
 
 
Reported: 2002-06-27 03:08 UTC by Cameron Gregory
Modified: 2009-08-15 18:40 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
free memory on early return. script-fu.c and script-fu-server.c (7.22 KB, patch)
2002-06-27 03:18 UTC, Cameron Gregory
none Details | Review
Solves the leaks as stated in bug #108966. (822 bytes, patch)
2003-04-11 21:14 UTC, Pedro Gimeno
none Details | Review
Backport of the previous patch (1.20 KB, patch)
2003-05-13 00:24 UTC, Pedro Gimeno
none Details | Review

Description Cameron Gregory 2002-06-27 03:08:49 UTC
Actually it leaks a lot of memory.
in 4 hours, I saw a script-fu up to 96 meg.
Mind you, it was working very hard!
Included after this are some patches...
It does not fix all the problems.

Cameron
Comment 1 Cameron Gregory 2002-06-27 03:18:09 UTC
Created attachment 9477 [details] [review]
free memory on early return. script-fu.c and script-fu-server.c
Comment 2 Sven Neumann 2002-06-28 13:08:52 UTC
We need to call gimp_destroy_paramdefs() on the params and
return_values returned from gimp_query_procedure(). Cleaning up with
g_free() will
leak lots of memory. I'd appreciate if you could change this and
create a new patch. And please try to avoid C++ style comments.
Comment 3 Sven Neumann 2002-06-28 13:12:33 UTC
For GIMP-1.3 we should consider to allow to pass NULL pointers to
gimp_procedural_db_proc_info() for the values we are not interested
in. This would avoid unnecessary memory allocation and would reduce
the risk of memory leaks.
Comment 4 Sven Neumann 2002-06-28 13:33:24 UTC
Looking at your patch a little more I think we should introduce a
cleanup label at the end of the function that frees all the memory and
use a goto to jump there in case of errors. That way we can avoid to
duplicate the code that frees the allocated resources at each and every 
return point.

The GimpParam args array should be allocated using g_new0() and needs
to be freed using gimp_params_destroy(). If you use g_free() you'll
leak quite a bunch of memory if any string or array types have been
allocated.
Comment 5 Sven Neumann 2003-03-26 11:24:53 UTC
*** Bug 108966 has been marked as a duplicate of this bug. ***
Comment 6 Pedro Gimeno 2003-04-11 21:14:50 UTC
Created attachment 15651 [details] [review]
Solves the leaks as stated in bug #108966.
Comment 7 Sven Neumann 2003-04-12 13:00:15 UTC
Applied to the HEAD branch. Should be considered for 1.2 as well.
Does this close the bug-report or are there obviously more leaks?

2003-04-12  Sven Neumann  <sven@gimp.org>

  * plug-ins/script-fu/siod-wrapper.c (marshall_proc_db_call):
  applied a patch from Pedro Gimero that plugs a memleak in Script-Fu.

Comment 8 Pedro Gimeno 2003-04-17 12:30:02 UTC
There's still the problem of leaks on early return that the OP tried
to address in his patch.

Of course, it would be even better to have a function like
gimp_procedural_db_get_proc_api that does not allocate useless stuff
like names or descriptions; this would also make PDB calls faster. But
that's just a thought.
Comment 9 Pedro Gimeno 2003-05-13 00:24:02 UTC
Here's a backport of the previous patch, to solve some of the leaks in
1.2. Leaks in error handling are still pending in both branches.
Comment 10 Pedro Gimeno 2003-05-13 00:24:54 UTC
Created attachment 16475 [details] [review]
Backport of the previous patch
Comment 11 Sven Neumann 2003-05-13 10:59:40 UTC
Please commit.

I don't think we should care about leaks on early returns in the
stable branch. The changes would likely introduce new bugs.
Comment 12 Pedro Gimeno 2003-05-13 14:54:52 UTC
Fully agree. Indeed I had already patched 1.3 in my local tree but
wasn't happy with the result. The patch above is now applied to 1.2:

2003-05-13  Pedro Gimeno

	* plug-ins/script-fu/script-fu.c: Merged a partial fix for
	bug #86586 (memory leaks in script-fu) from HEAD.

	* tools/pdbgen/pdb/color.pdb (histogram): Call gimp_histogram_free
	when no longer needed.

	* app/color_cmds.c: Regenerated.

As the remaining issues are not going to be fixed in 1.2 and
constitute just a mild cause of leaks, I'm resolving this bug as FIXED.
Comment 13 Raphaël Quinet 2003-06-20 19:32:52 UTC
The fix is part of the stable release 1.2.4.  Closing this bug.