I wanted to confirm if I am using the bit shift operators correctly.
1) In the first part, does it mean byte[] buffer = new byte[16 * 2 to the power 16] ? what is the memory size ?
2) In the second part what buffer size am I allocating ?
Am I at risk of running out of memory in any case if say I have 3 threads running each handling a 800 MB file ?
Thanks in advance.
Time is what we want the most, but what we use the worst. -- William Penn
Tom Reilly
Rancher
Joined: Jun 01, 2010
Posts: 618
posted
0
Try looking at buffer.length to see if you did it right.
Campbell Ritchie
Sheriff
Joined: Oct 13, 2005
Posts: 32712
4
posted
0
Yes, 16 << 16 is 16 * 1^16. But surely you would use hex and write 0x10?
Try this
As for the bit about memory, that is hardly a "beginning" topic, so I shall move this thread.>
Campbell Ritchie
Sheriff
Joined: Oct 13, 2005
Posts: 32712
4
posted
0
I earlier wrote: . . . I shall move this thread.
. . . and I presume you found the mistakes in my posting?
2) In the second part what buffer size am I allocating ?
Am I at risk of running out of memory in any case if say I have 3 threads running each handling a 800 MB file ?
Any help would be appreciated...
Why don't you tell us? .. in this topic, it was recommended that ... (1) you print out the buffer length, (2) you print out the value calculated from the expression, or (3) you work out the math on paper. Each of these options are easy and can be done in a few minutes.
As for running out of memory, we don't know the amount of memory of your machine, nor how much heap you have configured for your JVM.
Robin John wrote:
and I meant to quote only the memory part... before I could edit it.. you have replied : )
Well, what was the result? The number of elements in the byte array should tell you closely, the memory that your application needs (just for the array).
In this case, it's only cool if it actually accomplishes something useful, which it doesn't: back before optimizing compilers, when we were writing in assembly, etc. a shift made sense. That hasn't been the case for quite some time now.