senseiwells / EssentialClient

EssentialClient is a client side mod originally forked from Carpet Client for 1.15.2 that implements new client side features
MIT License
77 stars 14 forks source link

Memory leak / ConcurrentModificationException with harsh script usage #25

Closed aria1th closed 2 years ago

aria1th commented 2 years ago

it happened while testing my placeAt function. memory usage sums up for some reason, and excessive use would cause concurrentmodificationexception : null and crash client.

used script:

client = getMinecraftClient();
player = client.getPlayer();
world = client.getWorld();

fun isSpawnableBlock(x,y,z){
return (world.getBlockAt(x,y,z).getBlockId().containsString("air") && world.getBlockAt(x,y+1,z).getBlockId().containsString("air") && world.getBlockAt(x,y-1,z).getBlockId() == "stone") ;
}

centerX = 0.5;
centerY = 0.5;
centerZ = 0.5;

placeCount = 0;

radius = 129;

x = centerX-radius;
while (x <= centerX+radius){
y = centerY-radius;
while (y <= centerY+radius){
z = centerZ-radius;
while (z <= centerZ+radius){
ax = x;
ay = y;
az = z;
if ((ax-centerX) ^2 + (ay-centerY)^2 + (az-centerZ)^2 > radius * radius) {z = z+1;continue;}

if(isSpawnableBlock(ax,ay,az)){
player.placeAt(ax,ay,az);
placeCount = placeCount + 1;
sleep(65);
}

z = z+1;
}
y=y+1;
}
x=x+1;
}

I was testing with Rug, at creative mode, allowing Any block placing action with extended reach in single player. upper code will crash client, but if I add some 'pause' if (placeCount > 384) { placeCount = 0; sleep(5000);}

then it does not crash.

Kariaro commented 2 years ago

If you could provide the stacktrace/log debugging this issue would be easier. :D