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? -

html - Unable to style the color of bullets in a list -

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