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
Post a Comment