Jump to content

1.9 Gigs to run a script


avid

Recommended Posts

Ello all, thanks for stopping by!

Running a combat script I made. Pretty new to programming within a JVM. However, task manager (windows) is reporting 1.9gigs of memory usage (with render turned off and low cpu)... Is my script just THAT BAD?

 

I have web walking in a section, but it should only be called when we are outside of the combat area for whatever reason. 

 if(!targetArea.contains(myPlayer()) && !myPlayer().isAnimating() && !myPlayer().isMoving()) {
            log("webwalk event");
            WebWalkEvent evt = new WebWalkEvent(targetArea);
            evt.setBreakCondition(new Condition() {

                @Override
                public boolean evaluate() {
                    return dialogues.inDialogue();
                }
            });
            execute(evt); 
        }

Is this causing 1.9 gigs of memory usage? Is there any way to manually GC while the event is not in use?

 

Is there something else causing the massive memory usage? The filter for enemy acquisition? Surely the area's are stored as points in some way and not taking up globs of memory? Are there any other data structures I should be keeping an eye on for memory usage when using the API?

Appreciate your experience,
Avid

Link to comment
Share on other sites

If you think this walking method might be the cause, then just comment it out and run the bot. Take a look at the usage and see if there's any difference.

Anyways, you could try setting it as a global value and initiating it during onStart. That way you just call execute instead of creating it every time. 

(edit: ^ the walking event)

 

Edited by dreameo
Link to comment
Share on other sites

3 minutes ago, dreameo said:

If you think this walking method might be the cause, then just comment it out and run the bot. Take a look at the usage and see if there's any difference.

Anyways, you could try setting it as a global value and initiating it during onStart. That way you just call execute instead of creating it every time. 

(edit: ^ the walking event)

 

Good idea!

Does java work like that though, where it allocates memory for the object regardless of whether it's code block is entered? I guess that makes sense. (Been a while since I've worked in a pre-compiled language). I'll comment out the walking and see if that's the cause. If it is, could this be avoided via encasing the webwalk even in a function call? 

On that matter, would it be more memory efficient to hard code multiple paths through a dungeon and then only use the webwalker for banking? (rather than using the webwalker to enter/exit/navigate floors on the dungeon?)

Link to comment
Share on other sites

1 minute ago, avid said:

Good idea!

Does java work like that though, where it allocates memory for the object regardless of whether it's code block is entered? I guess that makes sense. (Been a while since I've worked in a pre-compiled language). I'll comment out the walking and see if that's the cause. If it is, could this be avoided via encasing the webwalk even in a function call? 

On that matter, would it be more memory efficient to hard code multiple paths through a dungeon and then only use the webwalker for banking? (rather than using the webwalker to enter/exit/navigate floors on the dungeon?)

It will only create it if it enters the block. webwalkers I think might be a bit expensive in creating. That's just the part of the code you showed so that's the only advice I could offer lol.

 

Making a path is more efficient then a web walker. Just use the Walking class and do walkPath. 

  • Like 1
Link to comment
Share on other sites

25 minutes ago, avid said:

I had a NPE going on in the combat portion. That was adding 1gig of memory usage! It's down to .9 gigs now. Which works for my setup right now. When I need to reduce it more, I'll fiddle with paths and walking instead of webwalker. Thanks again.

Glad you figured it out. If you go to options>console you can bring up the console to see errors thrown (not sure if you knew this but I figured you might not have known if you posted here before finding the NPE!). Alternatively you can boot from cmd and have it print there, using System.out.println.

In terms of walking, i'd suggest against using the webwalker liberally. As a general rule of thumb, the only occasion you should warrant using the webwalker is when you know where you are going but not where you are walking from. Use paths for the rest!

Best

Apa

  • Like 1
Link to comment
Share on other sites

On 12/5/2017 at 10:12 AM, Apaec said:

Glad you figured it out. If you go to options>console you can bring up the console to see errors thrown (not sure if you knew this but I figured you might not have known if you posted here before finding the NPE!). Alternatively you can boot from cmd and have it print there, using System.out.println.

In terms of walking, i'd suggest against using the webwalker liberally. As a general rule of thumb, the only occasion you should warrant using the webwalker is when you know where you are going but not where you are walking from. Use paths for the rest!

Best

Apa

Or just invest a little more money and use the webwalker all the time :) Like me! No more work required to do manual paths. Love the webwalker :).

Edited by Antonio Kala
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.
Note: Your post will require moderator approval before it will be visible.

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...