Why the perl script becomes slower?

Hi, I have a perl script which is like this:

foreach my \$loop(@\$Loops)

{        

Modules->DMol3->GeometryOptimization->Run(\$tdoc);

my \$start_time=time();

&Generate_XYZ_File();

print "Save Time: ", time()-start_time, "\n";

}

The Generate_XYZ_File() should cost the same time in every loop, but it seems it costs more and more time. Here is the output:

Save Time: 0.00639605522155762

Save Time: 0.0332968235015869

Save Time: 0.0339381694793701

Save Time: 0.0348000526428223

Save Time: 0.0345499515533447

Save Time: 0.0418829917907715

Save Time: 0.0433168411254883

Save Time: 0.0445859432220459

Save Time: 0.0981059074401855

Save Time: 0.105603218078613

Save Time: 0.107672929763794

Save Time: 0.108800888061523

Save Time: 0.110013961791992

Save Time: 0.111901998519897

Save Time: 0.113842964172363

Save Time: 0.118997097015381

Save Time: 0.122020959854126

Save Time: 0.13809609413147

Save Time: 0.140220880508423

Save Time: 0.203678846359253

Save Time: 0.211641073226929

Save Time: 0.20999002456665

Save Time: 0.213142871856689

Save Time: 0.21753191947937

Save Time: 0.219533920288086

Save Time: 0.222334861755371

Save Time: 0.227521896362305

Save Time: 0.299970865249634

Save Time: 0.323470830917358

I checked the *.outmol file generated by DMol3, the calculation speed keeps the same between different loops. So the only explaination is that there is more and more overhead to call Generate_XYZ_File() function. Is there a way to solve this problem? Thanks.