Yeah right. How is integer = 1 byte?
This code doesn't even compile. The array is TOO BIG.
Printable View
Yeah right. How is integer = 1 byte?
This code doesn't even compile. The array is TOO BIG.
It's NOT pointless. The user might have specified an improper path or made a mistake in the input filename. In that you should notify the user and not terminate the application.
Or you might start writing better code!
Where the hell do you think that big array is placed?
Even so, on Windows, you only have 2 GB of virtual memory and 4 GB > 2 GB!
Try to compile with
int pname[0x6FFFFFFF/4];
That's 1 879 048 191 bytes of memory.
When I run the program, the swap file skyrockets from 1.27 GB to 3.06 GB.
So I guess it's placed in memory, after all! Just that it's too big to fit into physical memory at once!
It's still bad practice. When someone writes real program, they don't terminate the application that way.
Are you intending that to be main or a utility function?
He didn't specify operating system.
It's not my fault windows cannot cope with large memory demands.
Blame Bill Gates for that, you think with all his money he could fix it.
If you want to ensure the data is in one byte chunks then use char instead of int.
It worked fine when I did that. It ran in a couple of minutes, no crashs no problems.
I gig file created no problem!!
On another system it would have greated a 4 gig file with no problems.
Irrelevant.
No, it's your fault for using such a ridiculous amount of memory.Quote:
It's not my fault windows cannot cope with large memory demands.
The problem isn't as simple as you think it is. Do you even know WHY it's limited?Quote:
Blame Bill Gates for that, you think with all his money he could fix it.
But you used int! Not char!Quote:
If you want to ensure the data is in one byte chunks then use char instead of int.
With char, it works, sure. But that doesn't take away the fact that you're using one GB of memory for no reason. It's bloat, bloat, bloat, just bloat and a very, very, very poor example.Quote:
It worked fine when I did that. It ran in a couple of minutes, no crashs no problems.
I gig file created no problem!!
Not on a 32-bit system, no.Quote:
On another system it would have greated a 4 gig file with no problems.
No, unfortunately not.
First, 32-bit means we can only address 4 GB of memory (0xFFFFFFFF), and secondly, Windows must reserve memory for its internal functions and for drivers and other specific things. Therefore, Windows reserves a big of memory for itself, which application cannot use. Thus you cannot use 4 GB memory on a 32-bit system. Not even Linux can.
He said he wanted to write gig of data to a file.
I assumed he had one gig of data to write in some real world
application. I cannot imagine anyone in their right mind would
and to write one gig of 'x's in to a file.
I was therefore giving an example of how to write the data at 'top speed'.
So it aint bloat at all.
My processor can address more than 4GB of memory.
The fact windows cannot use it it probably down to the kind of programming
style you adhere too.
It is down to bad programming.
Shockingly bad programming.
My program on the other hand would run prefectly well on a machine capable
of addressing more than 4GB of memory where it not restricted by a pile of
crap called 'windows'.
Mine is an example of programming of the very highest standard possible infact.
Only 64-bit processors can in 64-bit mode and a 64-bit operating system!
(Of course, there is the PAE, or whatever it's called, but it's not common and it's definitely not intended for consumer desktops.)
NO! It's a processor limitation! Get your facts straight before you accuse someone!Quote:
The fact windows cannot use it it probably down to the kind of programming
style you adhere too.
NO!Quote:
It is down to bad programming.
NO!Quote:
Shockingly bad programming.
NO! Again, you should what little you really know. Get your facts straight - read up on how processors work before you start accusing me!Quote:
My program on the other hand would run prefectly well on a machine capable
of addressing more than 4GB of memory where it not restricted by a pile of
crap called 'windows'.
A 32-bit pointer simply CANNOT hold any values higher than 4 GB.
It is one of the poorest example I have seen. In fact, I've seen newbies write better code.Quote:
Mine is an example of programming of the very highest standard possible infact.