in reply to Re: memory leak
in thread memory leak

It is longtime for me to review my question,I find above answer.
I think I should write something about it:

My sample template file(xml) is about 10kB,and my out put file is about 12kB.Each xml file contain 30 variable to replace,and my database's table contain 44 column(about 2000char and 4 text type column).My program cycle a table to create html files,each record create a file from 12 template files.

I think your suggestion is correct,because my file has some characters coding by UTF-8 or GB2312.Maybe Text::Template can not treate it correctly.I didn't try to confirm it.

To avoid hacking code of Text::Template,I wrote this code to instead Text::Template:
# Original I use Text::Template to get $Text,
# I replace it by my owner subroutine.
my $Text=GetTextFromVar($mark,$linehash);

sub GetTextFromVar
{
    my $mark=shift; # template file's name
    my $linehash=shift;
    if($CurrentTemplateFile ne $mark) 
    # <- if the template file has been loaded into momory,don't load it next
    {
        # old use : $Template=Text::Template->new(TYPE=>'FILE',SOURCE=>$mark);
        open(FH,'<',$mark);
        $CurrentTemplateFile=$mark;
        local $/=undef;
        $CurrentTemplateContent=<FH>;
    }
    # old use : return $Template->fill_in(HASH=>$linehash);
    # old usage create memory leap
    my $content=$CurrentTemplateContent;
    while(my ($key,$value)=each(%$linehash))
    {
        if($key=~m/^\w+\d*$/)
        {
            $content=~s/\{\$$key\}/$value/g;
        }
    }
    return $content;
}
It takes 30 minutes to cycle 10000 record.Because I don't need to create html file online,that's enough.

Thanks for your help.