There's a memory leak in this script, but can't find it.
boolean isSplashing;
long magicxp;
private Predicate<NPC> suitableNPC = n ->
getMap().canReach(n) &&
n.getHealthPercent() > 0 &&
n.hasAction("Attack") &&
!n.isUnderAttack() &&
getMap().realDistance(n) < 15;
public int onLoop() throws InterruptedException {
isSplashing = true;
magicxp = getSkills().getExperience(Skill.MAGIC);
sleep(random(3600,4800));
if (magicxp == getSkills().getExperience(Skill.MAGIC)) {
isSplashing = false;
}
if (!myPlayer().isUnderAttack() || !isSplashing) {
if (getInventory().contains("Air rune") && getInventory().contains("Mind rune") && getInventory().contains("Fire rune")) {
java.util.List<NPC> npcs = getNpcs().getAll().stream().filter(suitableNPC).collect(Collectors.toList());
if (!npcs.isEmpty()) {
npcs.sort(Comparator.<NPC>comparingInt(a -> getMap().realDistance(a)).thenComparingInt(b -> getMap().realDistance(b)));
if (npcs.get(0).interact("Attack")) {
sleep(random(3000));
}
}
sleep(random(3000,4000));
} else {
stop();
}
}
return random(300,400);
}
Threw some stuff around to see if something changed. In like 4-5 hours the memory usage went from 600MB to 1.2GB.