Code: Select all
#include <list>
#include <string>
#include <Magick++.h>
int main(int argc, char** argv) {
std::string filename = argv[1];
std::list<Magick::Image> imageList;
readImages(&imageList, filename);
Magick::Geometry size;
size.width(100);
size.width(100);
std::list<Magick::Image>::iterator iter;
for(iter = imageList.begin(); iter != imageList.end(); ++iter) {
(*iter).resize(size);
}
writeImages(imageList.begin(), imageList.end(), filename + ".gif", true);
return 0;
}
(source image : http://wstatic.naver.com/w9/lg_naver_v3.gif)
valgrind report is
Code: Select all
==7374== Memcheck, a memory error detector.
==7374== Copyright (C) 2002-2006, and GNU GPL'd, by Julian Seward et al.
==7374== Using LibVEX rev 1658, a library for dynamic binary translation.
==7374== Copyright (C) 2004-2006, and GNU GPL'd, by OpenWorks LLP.
==7374== Using valgrind-3.2.1, a dynamic binary instrumentation framework.
==7374== Copyright (C) 2000-2006, and GNU GPL'd, by Julian Seward et al.
==7374== For more details, rerun with: -v
==7374==
==7374== My PID = 7374, parent PID = 7371. Prog and args are:
==7374== ./Magick++LeakTest
==7374== lg_naver_v3.gif
==7374==
==7374== Warning: set address range perms: large range 134217728 (undefined)
==7374== Warning: set address range perms: large range 134217760 (noaccess)
==7374==
==7374== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 5 from 1)
==7374== malloc/free: in use at exit: 47,622 bytes in 1,456 blocks.
==7374== malloc/free: 1,855 allocs, 399 frees, 135,321,821 bytes allocated.
==7374== For counts of detected errors, rerun with: -v
==7374== searching for pointers to 1,456 not-freed blocks.
==7374== checked 11,689,576 bytes.
==7374==
==7374== 304 bytes in 1 blocks are possibly lost in loss record 10 of 22
==7374== at 0x4A04B32: calloc (vg_replace_malloc.c:279)
==7374== by 0x3EA920FF12: _dl_allocate_tls (in /lib64/ld-2.5.so)
==7374== by 0x3EAAE06AC2: pthread_create@@GLIBC_2.2.5 (in /lib64/libpthread-2.5.so)
==7374== by 0x5066621: (within /usr/lib64/libgomp.so.1.0.0)
==7374== by 0x519FDF: VerticalFilter (resize.c:1910)
==7374== by 0x51A745: ResizeImage (resize.c:2232)
==7374== by 0x422DB8: Magick::Image::resize(Magick::Geometry const&) (Image.cpp:1675)
==7374== by 0x415B47: main (in /home/blue0sky/workspace/nivfs/libTest/Magick++LeakTest)
==7374==
==7374== LEAK SUMMARY:
==7374== definitely lost: 0 bytes in 0 blocks.
==7374== possibly lost: 304 bytes in 1 blocks.
==7374== still reachable: 47,318 bytes in 1,455 blocks.
==7374== suppressed: 0 bytes in 0 blocks.
==7374== Reachable blocks (those to which a pointer was found) are not shown.
==7374== To see them, rerun with: --show-reachable=yes
(sorry for my rough english ^-^;;)