Memory leaks when creating a simple empty image

Magick++ is an object-oriented C++ interface to ImageMagick. Use this forum to discuss, make suggestions about, or report bugs concerning Magick++.
Post Reply
drunkensapo
Posts: 23
Joined: 2013-08-14T15:40:56-07:00
Authentication code: 6789

Memory leaks when creating a simple empty image

Post by drunkensapo »

I'm testing magick++ memory management under linux and mac. On OSX I'm using this:

Code: Select all

> convert --version
Version: ImageMagick 6.8.7-7 Q16 x86_64 2014-01-10 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2014 ImageMagick Studio LLC
Features: DPC Modules
Delegates: bzlib fftw fontconfig freetype jng jp2 jpeg lcms ltdl png tiff x xml zlib
And testing a simple program that creates an image:

Code: Select all

#include <string> 
#include <iostream> 
#include <list> 
#include <Magick++.h>

using namespace std; 
using namespace Magick;

int main(int argc,char **argv) 
{ 
  try { 

	  InitializeMagick(NULL);

    // Create base image (white image of 300 by 200 pixels)
	  Color c=Color("white");
    Image image( Geometry(300,200), c );

	  //MagickCore::DestroyMagick();
  } 
  catch( exception &error_ ) 
    { 
      cout << "Caught exception: " << error_.what() << endl; 
      return 1; 
    }

  return 0; 
}
Running valgrind like this:

Code: Select all

valgrind --leak-check=full --tool=memcheck --dsymutil=yes test_memory
I get this:

Code: Select all

==2931== LEAK SUMMARY:
==2931==    definitely lost: 10,858 bytes in 4 blocks
==2931==    indirectly lost: 4,548 bytes in 13 blocks
==2931==      possibly lost: 10,808 bytes in 1 blocks
==2931==    still reachable: 836 bytes in 14 blocks
==2931==         suppressed: 26,222 bytes in 374 blocks
==2931== Reachable blocks (those to which a pointer was found) are not shown.
==2931== To see them, rerun with: --leak-check=full --show-leak-kinds=all
The memory lost is a considerable amount of the total memory used.
You can see the full valgrind output here: https://gist.github.com/juan-cardelino/8398855

Any ideas?
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: Memory leaks when creating a simple empty image

Post by magick »

We tried your program with ImageMagick 6.8.8-2, the current release. Valgrind returns no leaks:
  • ==36542== LEAK SUMMARY:
    ==36542== definitely lost: 0 bytes in 0 blocks
    ==36542== indirectly lost: 0 bytes in 0 blocks
    ==36542== possibly lost: 0 bytes in 0 blocks
drunkensapo
Posts: 23
Joined: 2013-08-14T15:40:56-07:00
Authentication code: 6789

Re: Memory leaks when creating a simple empty image

Post by drunkensapo »

In which platform did you tested it? Which OS, compiler, etc?
I will try to get that version on OSX and see what happens.
However, it is not always that easy to get that versions, specially for those relying on package managers like homebrew or apt under linux.
I will try to download and compile it just to test, Thanks.
drunkensapo
Posts: 23
Joined: 2013-08-14T15:40:56-07:00
Authentication code: 6789

Re: Memory leaks when creating a simple empty image

Post by drunkensapo »

Under ubuntu 13.10 with gcc 4.8.1 and magick 6.7.7-10 same program does no leak. I think this is a valgrind issue.

==12023== LEAK SUMMARY:
==12023== definitely lost: 0 bytes in 0 blocks
==12023== indirectly lost: 0 bytes in 0 blocks
==12023== possibly lost: 0 bytes in 0 blocks
==12023== still reachable: 1,767 bytes in 13 blocks
Post Reply