Win32::API memory leak?

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

I'm using Win32::API to access the FindFirstFile() system call.  It
works, but repeated calls have the effect of increasing Perl's memory
footprint (looking at the 'Process' tab of taskmgr.exe in Win2000 Server).

Here's the script that exhibits this behavior.  I commented out the call
to FindNextFile() since even the original FFF call is enough to show
the problem.

Is there a bug in Win32::API?  Or is my code at fault?

use strict;
use warnings;
use Data::Dumper; $Data::Dumper::Indent=1; $Data::Dumper::Sortkeys=1;
use Win32::API;

#$Win32::API::DEBUG = 1;

use constant ERROR_NO_MORE_FILES  => 18;
use constant INVALID_HANDLE_VALUE => -1;

Win32::API::Struct->typedef('FILETIME', qw(
    DWORD dwLowDateTime;
    DWORD dwHighDateTime;

Win32::API::Struct->typedef('WIN32_FIND_DATA', qw(
    DWORD    dwFileAttributes;
    FILETIME ftCreationTime;
    FILETIME ftLastAccessTime;
    FILETIME ftLastWriteTime;
    DWORD    nFileSizeHigh;
    DWORD    nFileSizeLow;
    DWORD    dwReserved0;
    DWORD    dwReserved1;
    TCHAR    cFileName[260];
    TCHAR    cAlternateFileName[14];

my $FindFirstFile = Win32::API->new('kernel32.dll', 'FindFirstFile', 'PS', 'N')
or die $^E;
my $FindNextFile  = Win32::API->new('kernel32.dll', 'FindNextFile', 'NS', 'I')
or die $^E;
my $FindClose     = Win32::API->new('kernel32.dll', 'FindClose', 'N', 'I')    
or die $^E;

while (1) {
    print "\n----- Hit ENTER to continue -----\n";

sub DirList {
    my $searchDir = shift;

    my $FileInfo = Win32::API::Struct->new('WIN32_FIND_DATA');
    my $searchHandle = $FindFirstFile->Call("$searchDir\*", $FileInfo);
    die $^E if ($searchHandle == INVALID_HANDLE_VALUE);

#    do {
            print 'filename = ',$FileInfo->,"\n";
#            print Dumper($FileInfo);
#    } while (my $result = $FindNextFile->Call($searchHandle, $FileInfo));
#    if (Win32::GetLastError() != ERROR_NO_MORE_FILES) {
#        die $^E;
#    }

    $FindClose->Call($searchHandle) or die $^E;

Site Timeline