On 05/01/2017 7:03 PM, Era Scarecrow wrote:
On Thursday, 5 January 2017 at 04:53:23 UTC, rikki cattermole wrote:
Well, you could create a fiber[0].
Fibers allow you to set the stack size at runtime.
[0] http://dlang.org/phobos/core_thread.html#.Fiber.this
Well that certainly does seem to do the trick. Unfortunately I didn't
get the next output because I ran out of memory to allocate/reallocate
over 2Gb :P
I suppose with a 64bit compiling the program might run a bit longer and
succeed further (with 24Gigs of ram), however the sheer amount of memory
required will make this little exercise more or less a waste of time.
Still that was an interesting way around the (stackframe) problem, one
I'll keep I mind (should i need it again).
void m() {
foreach(i; iota(6))
foreach(j; iota(6)) {
writefln("Ackerman (%d,%d) is : %d", i,j,ack(i,j));
}
}
int main(string[] args) {
Fiber composed = new Fiber(&m, 2<<28); //512MB
composed.call();
return 0;
}
results:
Ackerman (3,5) is : 253
Ackerman (4,0) is : 13
Ackerman (4,1) is : 65533
core.exception.OutOfMemoryError@src\core\exception.d(693): Memory
allocation failed
You're using more memory then need to:
foreach(i; 0 .. 6)
No need for iota.