Re: Translation error (out of memory) [long post ahead]
- Posted by Lnettnay Dec 14, 2017
- 1607 views
Hi peoples,
I'm back. This has been driving me nuts.
This is what I think I know.
I made a few changes while testing
-- call this s1.ex atom sum, exits, tstart = time() constant limit = 1_073_741_825 -- power(2, 30) + 1 exits = 0 for i = 1 to limit do exits += 1 sum = 0 for j = i to limit do sum += j if sum > limit then -- prints out every 1000 times through the loop if remainder(exits, 1000) = 0 then ? exits end if exit elsif sum = limit then printf(1, "from %d to %d adds up to %d\n", {i, j, limit}) end if end for end for printf(1, "%f seconds\n", time() - tstart) puts(1, "all done\n")
That works when compiled. euc -gcc -con -makefile s1.ex I put the -makefile so I could look at the generated code without having to cd to the source directory.
-- call this one s2.ex atom sum, exits, tstart = time() constant limit = 1_073_741_825 -- power(2, 30) + 1 exits = 0 for i = 1 to limit do exits += 1 sum = 0 -- change the loop to limit + 0 for j = i to limit + 0 do sum += j if sum > limit then -- prints out every 1000 times through the loop if remainder(exits, 1000) = 0 then ? exits end if exit elsif sum = limit then printf(1, "from %d to %d adds up to %d\n", {i, j, limit}) end if end for end for printf(1, "%f seconds\n", time() - tstart) puts(1, "all done\n")
I compiled it using euc -gcc -con -makefile s2.ex
And it gives me the same error:
couldn't alloc 16384 bytes Fatal run-time error: Your program has run out of memory. One moment please...
The only difference is adding 0 to the limit (I also tried multiplying by 1). So I looked at the generated code.
/** for j = i to limit do*/ //line below in main-.c for s2.ex _11 = NewDouble(DBL_PTR(_1limit_144)->dbl + (double)0);
Looking at the Windows task manager the memory used goes up until it hits 2000M and then it crashes. The number of exits printed is ~131M which is about 16 bytes per exit.
I also don't understand this
/** exit*/ goto L4; // [83] 117 goto L6; // [85] 110
If i comment out this line
_11 = NewDouble(DBL_PTR(_1limit_144)->dbl + (double)0);and change the test here
if (binary_op_a(GREATER, _1j_150, _11)){ to if (binary_op_a(GREATER, _1j_150, _1limit_144)){it runs correctly.
Or if I move this
DeRef1(_11); _11 = NOVALUE;from its original location after the L2: label to the L4: label and compile it works also.
I have no idea how to fix this in the translator. I can't even find a file that looks like it compiles to euc.exe
That's all folks, Lonny