473,387 Members | 1,641 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

STL Stream maximum filesize?

Hello All,

I am trying to read data from a textfile using std::ifstream.
The problem is that I have a very huge text file, approximately 4.8 GB.
When I use this file, the program I wrote refuses to read in every line of
the file,
after a while it just stops, it doesn't reach the last line of the file.
When I use smaller files it works perfectly.

Is there a maximum filesize limit for std::ifstream?
Or could this be an operating system or compiler issue?
(I use Borland C++Builder5 and Windows2000 with NTFS)

--Michel


Jul 19 '05 #1
8 9008
maybe there is a 4gig limit .. (i think) they use int as an counter ..
could try around the 4gb mark and then you'll see
On Thu, 18 Sep 2003 10:06:31 +0200
"Michel Rosien" <ro****@REMOVEcs.utwente.nl> wrote:
The problem is that I have a very huge text file, approximately 4.8
GB. When I use this file, the program I wrote refuses to read in every
line of the file,

Jul 19 '05 #2
Michel Rosien wrote in news:bk**********@ares.cs.utwente.nl:
Hello All,

I am trying to read data from a textfile using std::ifstream.
The problem is that I have a very huge text file, approximately 4.8
GB. When I use this file, the program I wrote refuses to read in every
line of the file,
after a while it just stops, it doesn't reach the last line of the
file. When I use smaller files it works perfectly.

There is probably a 2GB limit ( pow( 2, 31 ) ).
Is there a maximum filesize limit for std::ifstream?
Yes, what it is and how you find out (other than trying) with any
given implementation I don't know.
Or could this be an operating system or compiler issue?
(I use Borland C++Builder5 and Windows2000 with NTFS)



Rob.
--
http://www.victim-prime.dsl.pipex.com/
Jul 19 '05 #3
Michel Rosien wrote in news:bk**********@ares.cs.utwente.nl:

[repost - I sent the previous by accident before I was finnished]
I am trying to read data from a textfile using std::ifstream.
The problem is that I have a very huge text file, approximately 4.8
GB. When I use this file, the program I wrote refuses to read in every
line of the file,
after a while it just stops, it doesn't reach the last line of the
file. When I use smaller files it works perfectly.

Is there a maximum filesize limit for std::ifstream?
Yes, but its implementaion ( C++Builder5 in your case ) defined.
Its probably 2GB ( pow( 2, 31 ) ).
Or could this be an operating system or compiler issue?
(I use Borland C++Builder5 and Windows2000 with NTFS)


A simple solution may be to change the way your programme works
from:

yourprog bigfile

to:

yourprog < bigfile

And read you data in from std::cin, do write a small test programme
first, just to check std::cin doesn't have the same problem.

If that doesn't work you'll need a platform specific solution, goto
MSDN http://msdn.microsoft.com/ and look for CreateFile to start
with.

HTH

Rob.
--
http://www.victim-prime.dsl.pipex.com/
Jul 19 '05 #4
"Rob Williscroft" <rt*@freenet.REMOVE.co.uk> wrote in message
news:Xn**********************************@195.129. 110.130...
A simple solution may be to change the way your programme works
from:

yourprog bigfile

to:

yourprog < bigfile

And read you data in from std::cin, do write a small test programme
first, just to check std::cin doesn't have the same problem.


Thank you, I will try this

--Michel
Jul 19 '05 #5
"Rob Williscroft" <rt*@freenet.REMOVE.co.uk> wrote in message
news:Xn**********************************@195.129. 110.130...
A simple solution may be to change the way your programme works
from:

yourprog bigfile

to:

yourprog < bigfile

And read you data in from std::cin, do write a small test programme
first, just to check std::cin doesn't have the same problem.


I rewrote the program as you suggested, but it still has the same problem
after a while the program just stops reading from the file (the stream
fails)
It has read 7864320 lines of 81(+2) bytes each, after that it stops.
This is the exact same number as with the original approach.
The total number of lines it should read is 58720256

But the point where it stops reading is no where near 2GB or 4GB (622.5 MB)
I don't know what's going on here

I think I'll just try to split the file into multiple smaller files.
I've tried other large text files of up to 72 MB and they have no problems.

--Michel
Jul 19 '05 #6
Interesting where it stops

7864320 = 780000h exactly

"Michel Rosien" <ro****@REMOVEcs.utwente.nl> wrote in message
news:bk**********@ares.cs.utwente.nl...
"Rob Williscroft" <rt*@freenet.REMOVE.co.uk> wrote in message
news:Xn**********************************@195.129. 110.130...
A simple solution may be to change the way your programme works
from:

yourprog bigfile

to:

yourprog < bigfile

And read you data in from std::cin, do write a small test programme
first, just to check std::cin doesn't have the same problem.
I rewrote the program as you suggested, but it still has the same problem
after a while the program just stops reading from the file (the stream
fails)
It has read 7864320 lines of 81(+2) bytes each, after that it stops.
This is the exact same number as with the original approach.
The total number of lines it should read is 58720256

But the point where it stops reading is no where near 2GB or 4GB (622.5

MB) I don't know what's going on here

I think I'll just try to split the file into multiple smaller files.
I've tried other large text files of up to 72 MB and they have no problems.
--Michel

Jul 19 '05 #7
This will give you the size and is the correct way to discover it at
runtime.

#include <streambuf>
__int64 temp=std::numeric_limits<std::streamsize>::max();

Fraser.
Jul 19 '05 #8

"Michel Rosien" <ro****@REMOVEcs.utwente.nl> wrote in message
news:bk**********@ares.cs.utwente.nl...
Hello All,

I am trying to read data from a textfile using std::ifstream.
The problem is that I have a very huge text file, approximately 4.8 GB.
When I use this file, the program I wrote refuses to read in every line of
the file,
after a while it just stops, it doesn't reach the last line of the file.
When I use smaller files it works perfectly.

Is there a maximum filesize limit for std::ifstream?
Yes. It's

std::numeric_limits<std::streamsize>::max()
Or could this be an operating system or compiler issue?


The actual value is implementation dependent, yes.

-Mike
Jul 19 '05 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Alan Howard | last post by:
Just migrating some code from CDONTS to CDO and noticed some behaviour I want to verify. When using cdoSendUsingPickup the outgoing email spools to the local filesystem first before being routed...
7
by: Joey C. | last post by:
Hello, I'm designing a small "briefcase" program that will allow me to quickly upload, download, and delete files in a briefcase. The only real things that I have left to do are to design a...
4
by: Paul | last post by:
I have developed an ASP.NET web page with a VB.net for the code behind. I would like to redirect the output of the web page so I can send it as an Email. Or Redirect the HTTPResponse stream on...
2
by: Jean Bidule | last post by:
Hi, I installed phpmyadmin to test my site on my homecomputer. The table i want to "upload" in my mysql table is about 5 Mb but in phpMyadmin the maximum size is 2048 kb. Where can I change...
1
by: Brent | last post by:
Problems streaming PDF back to Internet Explorer are well-described here: http://support.microsoft.com/default.aspx?scid=kb;en-us;Q305153 The solution, however, is elusive. I thought I was...
4
by: Leon Friesema | last post by:
Howto get the filesize from a file on "the web" using the 2005 WebClient? TIA, Leon
23
by: Gerrit | last post by:
Hi all, I'm getting an OutOfMemoryException when I initialize a byte array in C# like this: Byte test = new Byte; I'm using ASP.NET 2.0. In ASP.Net 1.1 it works fine. So what am I doing...
1
by: Paulson | last post by:
Hi all I got a problem in my PHP code while uploading huge files The error is as follows __________________________________________________________________ $_FILE -...
4
by: Manikandan | last post by:
Hi, I'm working with XML serialization. I'm writing a xml file of huge size(above 500MB) I need to show the user the progress of writing to file using progress bar. For this i need to create a...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.