Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ice fill solver (very rarely) causing extreme lag #147

Open
TheDGOfficial opened this issue Aug 24, 2023 · 1 comment
Open

Ice fill solver (very rarely) causing extreme lag #147

TheDGOfficial opened this issue Aug 24, 2023 · 1 comment

Comments

@TheDGOfficial
Copy link

Basically this been happened a lot of times to me in the past and whenever it happens my memory allocation rate goes above upwards of 1 GB/s trash being generated and garbage collected by the JVM, which makes the game have extreme lag and makes it unplayable. I always restarted to fix it and kinda lived with it, although everytime I tried to find the cause as well before restarting; i always failed to find the cause.

I couldn't find the cause before because I only looked at heap dumps since i suspected a memory leak or something. But today I took thread dump and I saw the findSolution method is perhaps stuck in an infinite recursion. Why it doesn't give StackOverflowError and abort is beyond my understanding. Also I'm out of dungeons and it still keeps appearing on thread dumps a.k.a it still tries to find a solution.

Please use a loop instead of recursion and minimize/remove Point and ArrayList allocations altogether, and perhaps add a isInDungeons or even isInIceFillRoom check to not continue trying to find a solution if not in ice fill room or in dungeons.

Thanks

Screenshot from 2023-08-24 18-41-16
Screenshot from 2023-08-24 18-43-26

@TheDGOfficial
Copy link
Author

Oh just noticed the IceWalkSolver class, I only looked to IceWalkUtils while creating the issue. Seems like there are checks for is in ice walk room, but they are not volatile nor atomic so my guess is there's a concurrency issue here. Everything inside the new thread should use thread-safe logic or the multi threaded block scanning should just be removed to be honest, it shouldn't take that long to find the solution anyways? Especially since, to my knowledge, the room is not randomized or anything at all and a constant solution might very well work.

Also looking at that class I realized this probably silverfish walk puzzle and not ice fill. My bad.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant