Memory Leak Issue: Scene Interpreter

An issue with the scene interpreter was reported 6 months ago by a member of the RPGMakerWeb community, Sixth, in the comments section for Scene Interpreter. Unfortunately, the report went unnoticed on my part and the issue continued to persist.

I have implemented a fix offered by Mithran for now. If possible, please update the script. I apologize for the inconvenience this may have caused for anyone that has used this script in their releases.

Below is an explanation of the problem and how it (probably) happened, as I don’t exactly remember the decisions that were being made when I originally wrote the script.

The Message Problem

It all begins with the creation of message windows.

The scene interpreter’s role is to allow you to basically run common events in any scene by creating a comment and writing

<run scene: current>

So for example, let’s say you used an item from the item menu, and the item called a common event. By default, the item menu would close and you would go back to the map, where the common event would execute. By using this script, the common event would execute directly in the item menu.

Most event commands work fine, but a number of commands did not because they relied on things that may not exist in the current scene. In particular, messages weren’t shown in scenes because there just wasn’t a message window available for the scene.

Introducing a “Scene Message Window”

My solution was to create a message window for every scene. Seems simple enough: whenever a scene starts up, just create a message window. Now you can just run your common event, and if text needs to be displayed, the scene’s message window will go ahead and read it.

Duplicate Messages

One problem I ran into was that when you showed messages on the map, a duplicate message would be shown. So you would run an event, and a message would be displayed. Once you close the message window, you’ll see another message window underneath it.

I then realized two message windows were being created: one of them was the “scene message window”, and the other is the default message window that the map was creating already.

I think what happened here is I decided to simply define the message window the same way as the ones found in Scene_Map and Scene_Battle

def create_message_window
  @message_window = Window_SceneMessage.new
end

So our message windows are still being created twice, but the second time it’s created, it will simply replace the old one and carry on with that.

Memory Leak

Of course, that assumption was wrong. While the reference to the old message window was lost, it was not properly disposed. Over-time, more and more of these old message windows started to accumulate, consuming more memory.

Eventually, as some developers have found out, the performance of their game became very sluggish over-time since the game could not get rid of all these message windows.

Fixing the Leak

At this point, I have not figured out a proper way to address the issue. The solution offered by Mithran was to avoid replacing the reference:

class Scene_Map
  def create_message_window
    @message_window = Window_Message.new unless @message_window && !@message_window.disposed?
  end
end

class Scene_Battle
  def create_message_window
    @message_window = Window_Message.new unless @message_window && !@message_window.disposed?
  end
end

This would take care of the issue for the map scene and battle scene, but if you have any other scenes that are also creating message windows, the issue would occur again.

Evidently, the decision to resolve the duplicate message window issue by simply “replacing” it and hoping the game would clean up the reference was wrong and the consequences are devastating.

 

You may also like...

19 Responses

  1. Zublxi says:

    buy clozapine tablets – ramipril 10mg usa pepcid 40mg sale

  2. Oocmku says:

    buy zidovudine 300 mg online – order metformin pills buy zyloprim 300mg

  3. Brsfck says:

    purchase glucophage generic – order bactrim 960mg for sale lincomycin 500 mg cheap

  4. Efohxq says:

    lasix 100mg cost – atacand 16mg uk capoten pills

  5. priscillawheuer says:

    Disposable provides convenience and portability with pre-filled devices ready for immediate use. Enjoy hassle-free vaping without the need for refilling or charging, perfect for on-the-go enthusiasts.

  6. Nhnxlm says:

    brand flagyl 200mg – cleocin over the counter purchase zithromax pill

  7. Hwxips says:

    ampicillin canada order monodox for sale amoxicillin for sale

  8. Uouira says:

    order valtrex 500mg pills – buy vermox 100mg pills zovirax 400mg pill

  9. Axnevi says:

    ivermectin 12 mg oral – purchase co-amoxiclav generic buy sumycin no prescription

  10. Bcemdz says:

    stromectol cost – order generic aczone cost tetracycline 500mg

  11. Dzqokc says:

    flagyl 200mg uk – buy generic cefaclor for sale azithromycin 250mg price

  12. Gprvhb says:

    ciprofloxacin 500mg without prescription – buy tindamax for sale purchase erythromycin without prescription

  13. Ftngmt says:

    cipro 1000mg without prescription – ethambutol brand augmentin 625mg uk

  14. Fxsnkz says:

    buy cheap generic baycip – buy generic myambutol for sale augmentin 625mg pill

  15. Xpsbvt says:

    atorvastatin 40mg price atorvastatin 80mg oral lipitor drug

  16. fynmorph says:

    Just in case you don’t see my post on rpgmaker.net

    I think i found a bug. When you call an event that changes a stat (say, remove 1 HP), it doesn’t refresh properly, it’s always 1 step back (and when you leave the menu and open again, it’s properly displayed now).

    Here’s a demo: http://puu.sh/kVKlS/6791692c00.rar
    Use the potion (it adds +1 max HP without script and remove 1 HP with script call).

  17. Sixth says:

    Ahoy!
    Just hopped in to say, that the fix itself was not made by me, I just reported the issue.
    I don’t use that script, but one of my friend uses it, and I saw the issue in his game.
    Mithran was the one who wrote the fix I posted originally.
    Good to see that the script is updated!

Leave a Reply

Your email address will not be published. Required fields are marked *