I am trying to execute essentially the code below. I create an array of file streams and then open all of them and write something to them. The problem is that for some reason if balls is greater than 508, it doesn't create the files anymore... Yes, the number 508. Even if I try to manually create the 509th stream after the loop, it will not create it (does not appear the directory). This happens if I try to make balls any value greater than 508 and the only way I have found to get it to go past this is to close some or all of the previous streams. I really want to be able to have 2000 streams open through the duration of the program run time before closing them, but I am assuming this has something to do with a memory limit. How much space does it take to have a simple file stream open? I have an i7 3770k which has decent cache sizes, 64 bit machine, and 16G of memory. Note that this occurs even just with the x,y,z etc string being written and nothing else. It's a tiny file.
#include <fstream>
#include <iostream>
const int balls = //Whatever I want...;
std::ofstream ballWrite[balls];
int main(){
// Open all file streams:
for (int Ball = 0; Ball < balls; Ball++)
{
ballWrite[Ball].open("ball" + std::to_string(Ball) + ".csv", std::ofstream::app);
ballWrite[Ball] << "x,y,z,w_x,w_y,w_z,w_mag,radius,mass,moi\n";
}
}