PDA

View Full Version : Memory usage of ruby



Tgo01
08-01-2014, 01:55 PM
So I'm in the process of moving over to WizardFE from Stormfront because the memory usage is much less, like 95% less when the memory leaks of Stormfront start kicking in.

But I've also noticed that ruby seems to do something similar. It starts out pretty low, 120ish megs but after a while sometimes it shoots up to over half a gig. Is this just bound to happen eventually from using lich or does it have something to do with how many scripts I'm running or what those scripts are doing?

Tillmen
08-01-2014, 02:14 PM
I'm not absolutely sure, but I believe that defining the same function or class over and over again causes a memory leak in Ruby 1.8. I haven't looked to see if it happens in later versions. It probably doesn't, because I remember reading somewhere that this was a known bug, and Ruby 1.8 is really old.

Another issue is that once script settings are loaded into memory, they don't get unloaded. This reduces lag for scripts that start and stop frequently, but it also means you have a lot of settings in memory that aren't being used at any given time.

You should test out Ruby 2.0 and Lich 4.5 and see if it changes anything.

Tgo01
08-01-2014, 02:18 PM
You should test out Ruby 2.0 and Lich 4.5 and see if it changes anything.

I'll give it a shot. Isn't this part of your plan to break all of our scripts though? :(

Tillmen
08-01-2014, 02:33 PM
I'll give it a shot. Isn't this part of your plan to break all of our scripts though? :(

I'm not sure anymore. So far I haven't changed anything that should break your scripts. Although Ruby 2.0 may break some scripts just because of the changes in the language.

Buckwheet
08-01-2014, 02:40 PM
I have been using 2.0 for ~2 months now and almost all the scripts were still working.

Tgo01
08-01-2014, 03:17 PM
So far so good. One instance of ruby jumped up to 174megs after running go2 but it's stayed pretty stable since then.

Tgo01
08-01-2014, 03:23 PM
What does this error message indicate?

--- Exception: break from proc-closure
:290:in `block (2 levels) in start_script'

This is the line causing it:

(wander.call;break) if other_players != nil

This is on one of the earlier scripts I wrote and it looks like that whole block of code could use some revamping. Is it possible the break isn't necessary where it is and that's what the error is pointing out?

The Lawlessness of Obama
08-01-2014, 03:27 PM
Memory leaks are such insidious things. They can be so difficult to track down.

Tgo01
08-01-2014, 04:49 PM
This is on one of the earlier scripts I wrote and it looks like that whole block of code could use some revamping. Is it possible the break isn't necessary where it is and that's what the error is pointing out?

That might have been the problem. I rewrote that whole section and it's working now. Woot!


Memory leaks are such insidious things. They can be so difficult to track down.

Damn memory leaks!

Tgo01
08-02-2014, 11:14 PM
So far the new lich and ruby are working out really well. There still appears to be some memory leak issues but not nearly as bad as before. I think the highest I've seen was 210 megs so far whereas the older versions got over 500 megs at times.