Jump to content
The Undefeated

Memory leak

Recommended Posts

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.

Link to comment
Share on other sites

1 minute ago, The Undefeated said:

What is complex in your eyes?

nothing really just dont think you need a list for 1 target

 private Predicate<NPC> suitableNPC = n ->
            getMap().canReach(n) &&
                    n.getHealthPercent() > 0 &&
                    n.hasAction("Attack") &&
                    !n.isUnderAttack() &&
                    getMap().realDistance(n) < 15;
 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)));

 

Link to comment
Share on other sites

4 minutes ago, raijin said:

nothing really just dont think you need a list for 1 target


 private Predicate<NPC> suitableNPC = n ->
            getMap().canReach(n) &&
                    n.getHealthPercent() > 0 &&
                    n.hasAction("Attack") &&
                    !n.isUnderAttack() &&
                    getMap().realDistance(n) < 15;

 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)));

 

Oh yeah, copied it from Macro killer, just because I was that lazy. But still doesn't fix the memory leak..

 

Edited by The Undefeated
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...