Jump to content
View in the app

A better way to browse. Learn more.

OSBot :: 2007 OSRS Botting

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

General advice for debugging slow/unresponsive scripts?

Featured Replies

Hi guys,

I recently made a big expansion to a script of mine. I went from the classes Farming, Banking & Teleports to a script that contains about 13 classes total. The reason I mention this, is that since then my script eats about 500mb RAM (fair bit more than it did originally) and is sometimes unresponsive/takes a while to stop.

I've noticed this behaviour even when the script is looping in the "Farming" methods, despite this behaviour not existing before the additional classes were added. No changes have been made to the original classes so I am unsure why they now are a lot slower. I'm wondering if you guys have any generic tips/anecdotal advice on problems you have encountered causing similar behaviour.

Thanks!!

My best go-to's are to comment everything new and then uncomment it piece by piece so you know what works well, and then just log everything and track the log to see what is being logged during a period of lag/freezing.

You could be calling something an unreal amount of times and not know it, creating an object over and over, not caching info efficiently, or not creating optimal methods/loops in general.

Do you have multiple threads running, external API calls, web interfacing? Address things like that.

I agree with Ace. This sounds like your tring to use something that is null fixing this will help the memory issue. Fixes? Try/catch around the loop this is a bandaid for gun shot or null check everthing this is just a pain in the ass but saved me many heart aches . 

Follow questions to get a better answer.

  1. Can you stop the script after sometime or do you have to force kill it if this does happen?
  2. Do can you see the log?
  3. Is it only in one section of the script or you can't tell. 

 

 

  • Author
On 6/1/2020 at 9:59 PM, Nbacon said:

I agree with Ace. This sounds like your tring to use something that is null fixing this will help the memory issue. Fixes? Try/catch around the loop this is a bandaid for gun shot or null check everthing this is just a pain in the ass but saved me many heart aches . 

Follow questions to get a better answer.

  1. Can you stop the script after sometime or do you have to force kill it if this does happen?
  2. Do can you see the log?
  3. Is it only in one section of the script or you can't tell. 

 

 

1. Sometimes if I wait the script stops. Other times I have to force kill it. I’m guessing that after I’ve ran and stopped it too many times the client eventually becomes unresponsive and needs to be killed.

2. I can see the logs, there are no visible NPEs

3. It’s likely that it is one or more sections of the script. However I don’t think it’s code that is currently running (if that’s possible) as like I mentioned in the body the code in this loop worked fine before I added new classes. I’m guessing some errors occur during class/variable instantiation that cause these errors but don’t give visible NPEs etc.

Sorry I can't help you more. Its most likly something supper small.

17 hours ago, Impensus said:

I’m guessing that after I’ve ran and stopped it too many times the client eventually becomes unresponsive and needs to be killed.

 

Sounds like a mermory leak or a threading problem. 

If a memory leak limit recursion and making new objects.  

If a threading problem try this. (I like ExecutorSevices to kill all threads.)

Quote

private ExecutorService executor = Executors.newFixedThreadPool(5);//mine is 5 because i have 4 threads 
private Runnable runnable;
        runnable = () -> {

            if (isStoped()) {
               executor.shutdownNow();
               executorSend = null;
            }
            try {
                //1 time thread task but works like a loop
                executor.submit(runnable);
            } catch (Exception e) {
              	log(e)
                executor.submit(runnable);
            }

        };

 

 

17 hours ago, Impensus said:

I can see the logs, there are no visible NPEs

That sucks.

17 hours ago, Impensus said:

It’s likely that it is one or more sections of the script. However I don’t think it’s code that is currently running (if that’s possible) as like I mentioned in the body the code in this loop worked fine before I added new classes.

Maybe take out features add them back 1 at a time till you find the problem?

Create an account or sign in to comment

Recently Browsing 0

  • No registered users viewing this page.

Account

Navigation

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.