Lag caused by load_header and mouse script?

I'm having an issue with lag when I use the mouse cursor in the save screen. I'm using a modified version of Yanfly's Save Engine as well as Amaranth's Super Simple Mouse System.

There is no issue when I use the keyboard. I can bash up/down as fast as I can, and I do not notice any lag. When I try to mouse quickly between file names, however, the mouse becomes very jerky, and it might skip over several of the files. Despite that, F2 does not report any drop in frame rate.

I believe the issue is that when a new file is selected, the current save file's header is reloaded, and the file preview pane is redrawn. If this is the case, I'm looking for some input on the best way to fix this. My current thought is to just create preview windows for every save file when the scene is loaded and just have the current one be visible. The other option is to load the headers for every file into an array and redraw the preview pane based on that data. Or maybe I'm barking up the wrong tree.

Input or suggestions are greatly appreciated.

P.S. Sorry I'm on my phone, so I can't link directly to the scripts. It shouldn't be too important to see them though since I've explained what I believe the problem to be.
I would try pre-loading all data and then draw the windows from there instead of loading the headers everytime.


I wouldn't try drawing all the windows beforehand if it takes a long time and you're probably not going to use half of them anyways.


It's unfortunate that yanfly chose to store EVERYTHING in the header (and in fact appears to be duplicating all of the data from the contents), as the majority of data is not even used.
Oh, I've already removed the unneccesary data. 🙂 I assume it is the repeated file opening in general that is causing the lag issue.

I'll try the preloading method and see if it makes a difference.

Edit: Preloading the headers did not make a difference. After some more testing, it appears the source of the lag is from draw_face. To be specific, the disposing of the bitmap at the end. Bitmaps aren't disposed when character sets or other pictures are blt'd to the window. Is it really neccesary in just this instance?
Depending on what version of the mouse script you're using, I was asked in the later versions to make it scroll more slowly. You MAY just need to comment that bit out - the first few lines of the process_mouse_handling method in the 3 window-related classes handle that.
I had already noticed that change, but it was occurring before I added that update. Like I said in my edit above, I've figured out the issue is with disposing the bitmap in the draw_face method of Window_Base. I guess my only remaining question is how necessary that dispose is? If I look at other methods in Window_Base like draw_icon or draw_character, they don't bother disposing the temporary bitmap loaded to blt onto the window. draw_face seems to be the only method in Window_Base that feels the need to do so.


I can't say I understand a lot about the memory allocation end of programming languages (if that is even what dispose is about), so I just want to confirm if removing that dispose is a bad thing or if it doesn't really matter.
If you do remove it, does the problem go away? If it doesn't, then you better put it back, as something else must be causing it. If the problem does go away, it's worth looking into. (in other words, I don't really know)
Oh yeah, the problem disappears completely as far as I can tell when I remove the dispose call. My only concern is that I've seen some really strange errors pop up seemingly randomly when dispose methods get involved. But unless someone has some input on why that dispose call was even there in the first place, I guess this can be considered solved? I'll just make a mental note if I start getting seemingly random errors down the line.
Most of the disposal fright is due to this


http://forums.rpgmakerweb.com/index.php?/topic/17400-graphical-object-global-reference-ace/


But if yanfly isn't disposing everything...that's rather inconsistent.
The dispose call isn't in a Yanfly method. It's in the default draw_face method of Window_Base. Same with the default draw_icon and draw_character methods not having one.


[Edit] Looking at the link you posted, that particular error shouldn't occur in these circumstances. The bitmap is just temporarily created in the method so that it can be blt'd to the window's contents. There are no viewports involved. I'll leave the dispose line commented out for the time being and see how it goes.

Original thread: https://forums.rpgmakerweb.com/threads/lag-caused-by-load_header-and-mouse-script.20289/