digitalmars.D.learn - Getting core.exception.OutOfMemoryError error on allocating large
- Sparsh Mittal (10/10) Mar 03 2013 I am running
- John Colvin (4/14) Mar 03 2013 Assuming double.sizeof==8 on your machine, You're requesting
- Sparsh Mittal (7/10) Mar 03 2013 You are completely correct, however in C, one could do:
- John Colvin (6/16) Mar 03 2013 For a start, that's not equivalent. The C version is creating a
- zorran (11/11) Aug 18 2013 on my machine (core i7, 16 gb ram, win7/64)
- John Colvin (2/13) Aug 18 2013 Interesting... What happens if you use core.memory.GC.malloc?
- zorran (11/12) Aug 18 2013 enum long size= 1300_000_000;
- zorran (3/4) Aug 18 2013 i am using in sample import std.c.stdlib;
- John Colvin (3/15) Aug 18 2013 Well that proves malloc is actually allocating the memory.
- John Colvin (6/25) Mar 03 2013 Depending on your OS, you will of course have to take in to
- Sparsh Mittal (1/1) Mar 03 2013 Thanks. Yes, you are right. I will change my program.
I am running enum long DIM = 1024L * 1024L * 1024L* 8L ; void main() { auto signal = new double[DIM]; } and getting core.exception.OutOfMemoryError error. One option is to use short/int, but I need to use double. Also, on using large arrays, computer becomes slow. Is there no workaround at all, so that I can work on large arrays? Please let me know.
Mar 03 2013
On Sunday, 3 March 2013 at 14:05:02 UTC, Sparsh Mittal wrote:I am running enum long DIM = 1024L * 1024L * 1024L* 8L ; void main() { auto signal = new double[DIM]; } and getting core.exception.OutOfMemoryError error. One option is to use short/int, but I need to use double. Also, on using large arrays, computer becomes slow. Is there no workaround at all, so that I can work on large arrays? Please let me know.Assuming double.sizeof==8 on your machine, You're requesting 1024*1024*1024*8*8 bytes = 68GB, do you have that much RAM available?
Mar 03 2013
Assuming double.sizeof==8 on your machine, You're requesting 1024*1024*1024*8*8 bytes = 68GB, do you have that much RAM available?You are completely correct, however in C, one could do: const long DIM = 1024L * 1024L * 1024L* 8L ; int main() { double signal[DIM]; } which runs fine. So, I was sort of looking for some solution like this.
Mar 03 2013
On Sunday, 3 March 2013 at 16:02:31 UTC, Sparsh Mittal wrote:For a start, that's not equivalent. The C version is creating a static array, the D version is a dynamic one. The C version is allocated on the stack, the D on the heap. I'm pretty certain the C version doesn't actually work as 68GB will have completely clobbered the stack.Assuming double.sizeof==8 on your machine, You're requesting 1024*1024*1024*8*8 bytes = 68GB, do you have that much RAM available?You are completely correct, however in C, one could do: const long DIM = 1024L * 1024L * 1024L* 8L ; int main() { double signal[DIM]; } which runs fine. So, I was sort of looking for some solution like this.
Mar 03 2013
on my machine (core i7, 16 gb ram, win7/64) next code written core.exception.OutOfMemoryError: enum long size= 1300_000_000; auto arr = new byte[size]; but next code work fine: enum long size= 1300_000_000; byte * p = cast(byte *) malloc(size); i compiled in 64 bit mode i use keys: "dmc -c -m64 test.d"
Aug 18 2013
On Sunday, 18 August 2013 at 12:07:02 UTC, zorran wrote:on my machine (core i7, 16 gb ram, win7/64) next code written core.exception.OutOfMemoryError: enum long size= 1300_000_000; auto arr = new byte[size]; but next code work fine: enum long size= 1300_000_000; byte * p = cast(byte *) malloc(size); i compiled in 64 bit mode i use keys: "dmc -c -m64 test.d"Interesting... What happens if you use core.memory.GC.malloc?
Aug 18 2013
Interesting... What happens if you use core.memory.GC.malloc?enum long size= 1300_000_000; byte * p = cast(byte *) malloc(size); for(int i=0; i<size; i++) p[i]=1; ulong sum=0; for(int i=0; i<size; i++) sum += p[i]; writef("%d ", sum); // here written 1300000000
Aug 18 2013
On Sunday, 18 August 2013 at 12:40:42 UTC, zorran wrote:i am using in sample import std.c.stdlib; GC.malloc also written core.exception.OutOfMemoryErrorInteresting... What happens if you use core.memory.GC.malloc?
Aug 18 2013
On Sunday, 18 August 2013 at 12:40:42 UTC, zorran wrote:Well that proves malloc is actually allocating the memory. I'd say file a bug report. This should definitely work.Interesting... What happens if you use core.memory.GC.malloc?enum long size= 1300_000_000; byte * p = cast(byte *) malloc(size); for(int i=0; i<size; i++) p[i]=1; ulong sum=0; for(int i=0; i<size; i++) sum += p[i]; writef("%d ", sum); // here written 1300000000
Aug 18 2013
On Sunday, 3 March 2013 at 15:52:49 UTC, John Colvin wrote:On Sunday, 3 March 2013 at 14:05:02 UTC, Sparsh Mittal wrote:Depending on your OS, you will of course have to take in to account page file limits and swap partition sizes. Nonetheless, 68GB is a huge amount of memory to have in a single array, that's 8.6 billion numbers. In reality I doubt you will need that many.I am running enum long DIM = 1024L * 1024L * 1024L* 8L ; void main() { auto signal = new double[DIM]; } and getting core.exception.OutOfMemoryError error. One option is to use short/int, but I need to use double. Also, on using large arrays, computer becomes slow. Is there no workaround at all, so that I can work on large arrays? Please let me know.Assuming double.sizeof==8 on your machine, You're requesting 1024*1024*1024*8*8 bytes = 68GB, do you have that much RAM available?
Mar 03 2013
Thanks. Yes, you are right. I will change my program.
Mar 03 2013