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.

players.getAll() possible resource leak

Featured Replies

I'm writing a script where getPlayers().getAll() is called during every paint. When in a crowded area with lots of players, the client uses more and more cpu and ram until it needs to just be restarted. When left in an uncrowded area, it runs fine for days. I am 90% sure this isn't a bug in my code so I think it must be a problem with this method.

Edited by Diclonius

  • Developer

Loading every player in the paint every single time is fairly heavy indeed, is this really required? 

I personally try to stay away of loading lots of entities int he paint, due to high cpu usage.

 

Can't say anything about a memory leak though.. :s

 

Khaleesi

Cache it for a second or something, manually :E

 

Pretty sure there's no memory leak, but the garbage collector may not be able to keep up. Alternatively you can manually try to garbage collect every so often, but this will only further increase the CPU usage.

  • Author

I understand that it is quite intensive to load them every paint, but the problem is that the client uses more and more memory + cpu when the script is ran for more than a couple of hours. it runs smoothly when ran initially.

I understand that it is quite intensive to load them every paint, but the problem is that the client uses more and more memory + cpu when the script is ran for more than a couple of hours. it runs smoothly when ran initially.

 

I don't know what exactly you need that method for every onpaint.

But try updating outside the paint and store the data to re-use it in the paint.

This way it will be a lot less heavy.

private var someVar;


private void update() {
  for (Player player : getPlayers().getAll()) {
    if (condition) {
      someVar = x;
    }
  }
}

onLoop() {
  if (System.currentTimeMillis() - lastUpdate > 1500) {
    update();
  }
}

onPaint() {
  draw(someVar);
}

Edited by lisabe96

Guest
This topic is now closed to further replies.

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.