Jump to content

1.9 Gigs to run a script


Recommended Posts

Posted

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

Posted (edited)

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
Posted
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?)

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

Web walker data is loaded once when its called initially, then its not deallocated because we expect the call to be made again. For detailed output don't use the logger, the logger is meant for non-scripters. Run OSBot in Command-Line to see detailed outputs.

 

java -jar "osbot.jar -debug 5005"

 

Posted (edited)
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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

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