Ludii Forum
error: out of heap space - Printable Version

+- Ludii Forum (https://ludii.games/forums)
+-- Forum: Problems (https://ludii.games/forums/forumdisplay.php?fid=5)
+--- Forum: Ludii Player Problems (https://ludii.games/forums/forumdisplay.php?fid=6)
+--- Thread: error: out of heap space (/showthread.php?tid=563)



error: out of heap space - dale walton - 05-13-2021

I was trying to revise Throngs to find all the destinations in one go by using the union of 7 remembered lists of sites, got this error upon compilation.

Is there any way to tell the program to prepare more heap space?

Compiled Throngs successfully.
Exception in thread "AWT-EventQueue-0" java.lang.OutOfMemoryError: Java heap space
...


RE: error: out of heap space - DennisSoemers - 05-13-2021

If you launch from command line, you can try something like:

java -Xmx4096M -jar Ludii-1.1.18.jar

which would allow using up to 4GB (or 4096MB) of memory. Can use different numbers of course depending on your needs / hardware.


RE: error: out of heap space - dale walton - 05-13-2021

Thanks, I'll try.

That's not going to work for me as I only can manage about 1.7GB on my PC, which is not enough.
So I need to know what things are popping up the heap space requirements the most.

Attached is the code to let you see the problem clearly. It could be a bug is causing it, but it probably is simply the weight of the code.
I tried changing the (unions) to an and construction, but that probably doesn't make a difference.

Attachment added


RE: error: out of heap space - Eric Piette - 05-17-2021

Hi,

We found a bug in union for IntArrayFunction which can explain that. I just fixed it.
That should fix your memory issue.

Regards,
Eric


RE: error: out of heap space - dale walton - 05-17-2021

Ok, I will look forward to trying it out.

However, I also tried with using ands and selects, and also had the heap problem, and I tried instead to define the board as 3D in 8 layers (or even less) (in order insert pieces to store states associated to locations) but just defining the 3d board gave a similar heap problem, so I thought it might be intrinsic to the game.

To try to avoid heap space, I also tried using stacks of neutral pieces to record the movable positions, but found that the add move couldn't seem to be used as a separate consequence at a different level within the same chain of consequences. Which I guess makes sense.


RE: error: out of heap space - dale walton - 05-19-2021

OK, on checking that did solve the heap space requirement, but I had some other logic errors.  However when I corrected them, I get no result.



I suspect this is due to:

(sites) and/or (results) probably is returning -1 when  there are no values in (values Remembered) in (results from:(sites (values Remembered ...) ...) ...)


so following that, the (union) implementation goes to an error state?

- does it do so if any of the inputs is empty/error, or only if all of the inputs are empty/error?


So:
(forEach Value (union ...<is in error as above>...) (remember Value "S4" (value))


presumably just doesn't execute the (remember) -- but does it stop the (then in: 
(if (<condition>) (<error result>) (then ....)) from executing as well? (i.e. do I need to encapsulate in a series of do (if (...) (...)) next:(do...), instead of (if (...) (...) (then...) ? )  Edit: I made that change now just in case.


My understanding of what (union) should do is that, like an logical (or), it should ignore the empty/error arrays unless ALL of them are empty/error, but the lack of results makes me suspect that it is returning -1 if any of the inputs is -1. -- Or else that the subsequent (then)s are not executing, or both.



If this is the case, can you fix it, or provide an option on union to ignore invalid arrays?  -- It will be hard to script individually hiding empty arrays from the union function.

If I add dummy values to guarantee existence or the remembered values, then I would need to script exemptions for each of the from: lines - and it would only help if it is (sites) that is throwing up the invalid flag.



Attached is a version that shows this problem. The destinations are neither remembered not assigned to pending. This happened when I switched the  ">" to "<" in the find destination define, causing some of the remembered arrays to be empty. I later made other adjustments, but the problem still is no destinations get assigned. (click on an empty cell next to 2 pieces, or on a piece itself to verify this.


RE: error: out of heap space - Eric Piette - 05-19-2021

Hi,

Sorry, we have no idea what you mean here. What is the problem in the short terms?
I can just answer the union question, that's just a basic union set operator, nothing special about it.

Regards,
Eric


RE: error: out of heap space - dale walton - 05-19-2021

Problem is that sites should be remembered and added to pending when a selection creates a "PowerLeft" > 0, but they aren't, so the move can't be completed.


RE: error: out of heap space - Eric Piette - 05-20-2021

Hi,

I am still not able to help you. You have posted 2 files that are pretty long so I am not sure in details where to look.
Moreover, you seem to say that something is not done because of a condition, so in reading that, that sounds like a problem in the description.
If you think that's not a description problem but a bug in Ludii, I will need you to be able to send us a simpler (a single one) lud that has the same problem (and if that's not easy to replicate, a trial showing the problem).

Sorry to not be able to help you without all of that, but we can not look at each long file send by all our users to look for each problem (of description or not). I hope you can send some simpler instructions and examples of the problem you have here. Thanks for that.

Regards,
Eric