Check this out when running valgrind memory test on the previous posted perl script
==28945== Memcheck, a memory error detector.
==28945== Copyright (C) 2002-2008, and GNU GPL'd, by Julian Seward et
+al.
==28945== Using LibVEX rev 1878, a library for dynamic binary translat
+ion.
==28945== Copyright (C) 2004-2008, and GNU GPL'd, by OpenWorks LLP.
==28945== Using valgrind-3.4.0, a dynamic binary instrumentation frame
+work.
==28945== Copyright (C) 2000-2008, and GNU GPL'd, by Julian Seward et
+al.
==28945== For more details, rerun with: -v
==28945==
==28945==
==28945== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 29 from
+ 2)
==28945== malloc/free: in use at exit: 1,488,425 bytes in 28,258 block
+s.
==28945== malloc/free: 47,397 allocs, 19,139 frees, 16,246,146 bytes a
+llocated.
==28945== For counts of detected errors, rerun with: -v
==28945== searching for pointers to 28,258 not-freed blocks.
==28945== checked 2,423,200 bytes.
==28945==
==28945== 5 bytes in 1 blocks are definitely lost in loss record 1 of
+18
==28945== at 0x4004A41: malloc (vg_replace_malloc.c:207)
==28945== by 0x34D8E54: Perl_savesharedpv (in /usr/lib/perl5/5.8.5/
+i386-linux-thread-multi/CORE/libperl.so)
==28945== by 0x3486313: (within /usr/lib/perl5/5.8.5/i386-linux-thr
+ead-multi/CORE/libperl.so)
==28945== by 0x348A23B: perl_parse (in /usr/lib/perl5/5.8.5/i386-li
+nux-thread-multi/CORE/libperl.so)
==28945== by 0x8049339: main (in /usr/bin/perl)
==28945==
==28945==
==28945== 13,767 (1,299 direct, 12,468 indirect) bytes in 14 blocks ar
+e definitely lost in loss record 9 of 18
==28945== at 0x4004A41: malloc (vg_replace_malloc.c:207)
==28945== by 0x34D9BDA: Perl_safesysmalloc (in /usr/lib/perl5/5.8.5
+/i386-linux-thread-multi/CORE/libperl.so)
==28945== by 0x351D46F: Perl_new_stackinfo (in /usr/lib/perl5/5.8.5
+/i386-linux-thread-multi/CORE/libperl.so)
==28945== by 0x3483D8A: Perl_init_stacks (in /usr/lib/perl5/5.8.5/i
+386-linux-thread-multi/CORE/libperl.so)
==28945== by 0x34841CB: perl_construct (in /usr/lib/perl5/5.8.5/i38
+6-linux-thread-multi/CORE/libperl.so)
==28945== by 0x80492EE: main (in /usr/bin/perl)
==28945==
==28945==
==28945== 7,472 bytes in 3 blocks are definitely lost in loss record 1
+2 of 18
==28945== at 0x4006081: realloc (vg_replace_malloc.c:429)
==28945== by 0x34DA8EB: Perl_safesysrealloc (in /usr/lib/perl5/5.8.
+5/i386-linux-thread-multi/CORE/libperl.so)
==28945== by 0x351D7C8: Perl_savestack_grow (in /usr/lib/perl5/5.8.
+5/i386-linux-thread-multi/CORE/libperl.so)
==28945== by 0x351E42C: Perl_save_I32 (in /usr/lib/perl5/5.8.5/i386
+-linux-thread-multi/CORE/libperl.so)
==28945== by 0x34C3FDB: Perl_pad_block_start (in /usr/lib/perl5/5.8
+.5/i386-linux-thread-multi/CORE/libperl.so)
==28945== by 0x34B24C9: Perl_block_start (in /usr/lib/perl5/5.8.5/i
+386-linux-thread-multi/CORE/libperl.so)
==28945== by 0x34AEBA5: Perl_yyparse (in /usr/lib/perl5/5.8.5/i386-
+linux-thread-multi/CORE/libperl.so)
==28945== by 0x35295CB: (within /usr/lib/perl5/5.8.5/i386-linux-thr
+ead-multi/CORE/libperl.so)
==28945== by 0x352AF7C: Perl_pp_require (in /usr/lib/perl5/5.8.5/i3
+86-linux-thread-multi/CORE/libperl.so)
==28945== by 0x34D7DDC: Perl_runops_debug (in /usr/lib/perl5/5.8.5/
+i386-linux-thread-multi/CORE/libperl.so)
==28945== by 0x3482AE5: (within /usr/lib/perl5/5.8.5/i386-linux-thr
+ead-multi/CORE/libperl.so)
==28945== by 0x3488E6A: Perl_call_sv (in /usr/lib/perl5/5.8.5/i386-
+linux-thread-multi/CORE/libperl.so)
==28945==
==28945==
==28945== 144,708 bytes in 14 blocks are possibly lost in loss record
+17 of 18
==28945== at 0x4004A41: malloc (vg_replace_malloc.c:207)
==28945== by 0x34D9BDA: Perl_safesysmalloc (in /usr/lib/perl5/5.8.5
+/i386-linux-thread-multi/CORE/libperl.so)
==28945== by 0x34E4DE7: Perl_reentrant_init (in /usr/lib/perl5/5.8.
+5/i386-linux-thread-multi/CORE/libperl.so)
==28945== by 0x34843F0: perl_construct (in /usr/lib/perl5/5.8.5/i38
+6-linux-thread-multi/CORE/libperl.so)
==28945== by 0x80492EE: main (in /usr/bin/perl)
==28945==
==28945== LEAK SUMMARY:
==28945== definitely lost: 8,776 bytes in 18 blocks.
==28945== indirectly lost: 12,468 bytes in 27 blocks.
==28945== possibly lost: 144,708 bytes in 14 blocks.
==28945== still reachable: 1,322,473 bytes in 28,199 blocks.
==28945== suppressed: 0 bytes in 0 blocks.
==28945== Reachable blocks (those to which a pointer was found) are no
+t shown.
==28945== To see them, rerun with: --leak-check=full --show-reachable=
+yes
|