Question about memory (RAM) usage..

"

Hi all,

Is there a way how to avoid high memory usage while writing to a long file?

My system contains about 30k atoms and I want to print coordinates and charges of each atom to a txt file.

First few thousands of atoms it prints very fast, but after that it begun to go slower and slower. In principle for the last 30% of the system it took about 75% of the total time.

Best regards,

Bojan

"
Answers 2
BM
BM 2015-01-20

Hi

I assume that you are doing this within the context of Materials Studio and are you writing to a document in memory or are writing to a file on disk? In the former you will do something like

my $doc = Documents->New("Documents.txt");

...

$doc->Append(sprintf("%.4f %.4f %.4f\n",$x,$y,$z));

in the latter.

open my $out, '>', 'Documents.txt';

...

print {$out} "$x,$y$z\n";

etc

Depending on the internal implementation the information in a "Document" may be held in memory, so the more data you add, the more memory will be used!

If that is the problem, then writing to a .txt file using standard Perl IO may be more efficient.

Regards

Simon

CM
CM 2015-01-20

Perhaps it helps to get a faster disk and/or more RAM. Please run the script on the sever and not in Debug mode.