title: fclose() function slow
body: <p>I tried to create around 4 GB file using c++ fopen, fwrite and fflush and fclose functions on Linux machine, but I observed that fclose() function is taking very long time to close the file, taking around (40-50 seconds). I checked different forum to find the reason for this slowness, changed the code as suggested in forums, Used setvbuf() function to make unbuffered I/O as like write() function. but still could not resolve the issue.</p>
  
  <pre><code>        totalBytes = 4294967296 // 4GB file
          buffersize = 2000;    
          while ( size &lt;= totalBytes )
          {
              len = fwrite(buffer, 1, bufferSize, fp);
              if ( len != bufferSize ) {
                  cout&lt;&lt;"ERROR (Internal): in calling ACE_OS::fwrite() "&lt;&lt;endl;
                  ret = -1;
              }
              size = size + len;
          }
          ...
          ...
          ...
          fflush(fp);
          flcose(fp);
  </code></pre>
  
  <p>Any solution to the above problem would be very helpful.</p>
  
  <p>thanks,
  Ramesh</p>