c++ - Writing huge txt files without overloading RAM -


i need write results of process in txt file. process long , amount of data written huge (~150gb). program works fine, problem ram gets overloaded and, @ point, stops.

the program simple:

ostream f; f.open(filepath); for(int k=0; k<ndataset; k++){     //treat element of dataset     f << result; } f.close(); 

is there way of writing file without overloading memory?

you should flush output periodically.

for example:

if (k%10000 == 0) f.flush();  

Comments

Popular posts from this blog

html5 - What is breaking my page when printing? -

c# - must be a non-abstract type with a public parameterless constructor in redis -

ajax - PHP/JSON Login script (Twitter style) not setting sessions -