weirdest lag issue you will see ever, need help fixing it

So the main problem should be somewhere in your implementation script where it disposes the animation bitmaps.

Are you using any script that uses "class Sprite_Base < Sprite" ? Scripts that do animation speed modification and such?

Or a script that directly writes into "class Sprite"?

If a bitmap isn't being disposed correctly, Mithran's script should have picked it up by now, but well.. it's not 100% so there can be a miss.

It's going to be a huge and tiresome list but...

ctrl+shift+f and look for ".dispose", focus on your implementation script and see if you have commented out any lines doing a dispose.
l couldn't have commented out anything, l just took the original scripts from theoallen demo

im using core engine to make the animations go 60 frames http://puu.sh/kgu6r/6b797bf7a5.png

other scripts using this method, # = disabled http://puu.sh/kgu7D/80173f93f9.png
That's way too many scripts tapping into the sprite base class. I am not sure what those scripts are trying to do in there but the more they are, the easier it conflicts.

And umm.. try to remove all the scripts you are not using. It's not wise keeping them in the project you are making even though it's an older version you wish to keep. Simply make a .txt file somewhere on your PC and keep them there.

I still think there's something wrong with the termination of scene_battle since everything black listed just happened to be in that class. Animations may cause the memory usage to rise depends on the file size you use on the graphics. But they should be disposed after battle. And from what you are telling us, they aren't disposed after the battle ends. So there might be a chance of something being wrong in your Sprite Base class too.

This is as far as i can go without looking into the scripts and orders you are using, and with my time on hand, i won't be able to help much from here. But now that you have things narrowed down. With the commission you are trying to give, it won't be hard to get yourself someone to take care of the rest i guess. So wish you luck on progress! 😉
there is nothing wrong with my scripts, theoallen's own demo does the same error. expect l use 140k memory on startup while his uses 75k so the lag is less apparant

he is not active here nor on his own website anymore so maybe someone could just make some script like

<actor/enemies do their abilities during the turn

<turn end

<clear memory used from sequences in that turn

or if the freeze is too big then

<actor/enemy do a skill

<clear memory used from that sequence

then maybe the lag would be gone
He's still active as far as i can tell. And you can always get him on skype.

His last post a month ago:

http://www.theolized.com/2015/08/new-rpg-maker-announced-with-built-in.html

His Skype can be found here:

http://forums.rpgmakerweb.com/index.php?/user/568-theoallen/
this is still isn't solved, still hoping some very experienced scripters can take a look at this

in the meantime, l will disable scripts in theoallen's demo one by one and see if there is a memory drop just in case it isn't his implementation script
72h

putting a thread in classified requests soon, offer will be about $100 CAD for the fix
I can give it a go (if you pay me if I solve it). Send me a project with all the scripts you're using and enough graphical contents to make it work.

If you do that I might be able to solve it.

If I can make it trigger I can solve it.

I don't know what you're talking about most of the time and why you measured the memory dump. This is probably just a memory leak I have seen it countless times. And fixed it.

It's within an update method in one of your battle scripts that's where it can really Frick up your game and causes lag, just a small error from the programmer regarding creation of sprites

in an update method and it causes the lag, it's usually bad and lazy programming not testing your scripts before exposing them to the public, or it might be a compatibility issue.

I have seen much weirder stuff.
no need to give scripts, if you read the thread you would had seen that theo's TSBS is the problem with hidden sprites not being disposed

http://puu.sh/kqKJp/15a3334317.png battle start

http://puu.sh/kqKLB/06c2f03176.png after a few turns
Then please send me an empty project with your version of the battle script setup to trigger the memory dump (maybe an event that initializes a battle that triggers it), I can't make it work because lots of constants hasn't even been initialized.

I can't help you unless you do that.
ill just give you my whole project, $80 CAD is the reward now, l gave $20 already to my scripter for his current tries

the event is simple to trigger, make you and the enemies do as many skills as you can and actor sequences will start to lag up
What script are you using to display that un-disposed bitmap report? o.o


It looks amazing!


Btw, how many is "a few turns"? I'm asking because I want to test it in my project too, but even after 30 turns, I get no slowdowns at all.
Not sure why you are having 8 planes, thought the original game engine is using only 3~4?

Planes are normally used for parallax/tile map that scrolls in RM. (But i am not sure if they originally get disposed or not when changing from map to battle scene)

But any way, like i told you before, sprites are disposed at the termination of a scene/windows.

If they are not disposed within a same scene in play, it's normal. Especially those shown in your debugger are normally needed in a battle.

Bitmaps in that "hidden" sprite class, should be your text/font from UI/item/skill/battle log message. So yes, it will accumulate during a battle.

Animations (for skill, and probably your battle system is using its own sprite animations for side view battle), are one of those "big" sized graphic that can accumulate easily.

But to get it to lag a system in a single battle play, either your pc is having problem with memory handling or all other users that's using Theo's battle system has found a way to overcome it.

You said you get the lags after 15-20 turns right? So try this script call somewhere around turn 20(where it starts to lag) and see if that stops the lag.

GC.startThis script call force the ruby garbage collector to start and dispose unused bitmaps. (bitmaps no longer being referenced)

This is normally done automatically by the ruby core engine, but i can't be sure for rgss3.

And it seems like your debugger is also detecting sprites "outside" of rgss (or rather global referenced bitmaps).

So if you are getting lag in a single battle play and not AFTER the battle, there's a serious memory handling problem with your pc, my suggestion is.. give your pc a good scan for malware/viruses before continuing to find the problems in those scripts.
What script are you using to display that un-disposed bitmap report? o.o

It looks amazing!

Btw, how many is "a few turns"? I'm asking because I want to test it in my project too, but even after 30 turns, I get no slowdowns at all.
it's the tests of my scripter

few turns depending on how many skills the enemies/allies will have done, youll see your memory goes up everytime a skill is done. when its about double your initial memory, your actor sequences will start to lag.
I've investigated this issue and have pinpointed that at least these 2 scripts are certainly related to that:

▼Killozapit - Cache Back

▼Implementation v1.4

I modified them to these:

▼Killozapit - Cache Back(Line 230 - 243) -

Spoiler
# * Alias: Code run when a bitmap is erased/unloaded alias_method :cache_dispose, :dispose def dispose # Never dispose bitmaps with keep_cached set return if self.disposed? || @keep_cached # Don't despose chached bitmaps if the settings say to keep them if @cached && Cache::KEEP_DISPOSED_BITMAPS # Tell the cache to add this bitmap to it's list of bitmaps # to be disposed later (if BUFFER_DISPOSED_BITMAPS is true) Cache.add_dispose(self) if Cache::BUFFER_DISPOSED_BITMAPS else File.open("Diagnose.txt", "a") { |file| file.print("cache_dispose: #{self}\n") } cache_dispose end end
▼Implementation v1.4(Line 4663 - 4683) -

Spoiler
# -------------------------------------------------------------------------- # Alias method : dispose # -------------------------------------------------------------------------- alias tsbs_dispose dispose def dispose File.open("Diagnose.txt", "a") { |file| file.print("dispose: battler #{@battler ? @battler.name : "nil"}, @used_bitmap.include?(@anim_state.bitmap) #{@used_bitmap.include?(@anim_state.bitmap)}\n") } File.open("Diagnose.txt", "a") { |file| file.print("dispose: battler #{@battler ? @battler.name : "nil"}, @used_bitmap.include?(@anim_guard.bitmap) #{@used_bitmap.include?(@anim_guard.bitmap)}\n") } File.open("Diagnose.txt", "a") { |file| file.print("dispose: battler #{@battler ? @battler.name : "nil"}, @used_bitmap.include?(@shadow.bitmap) #{@used_bitmap.include?(@shadow.bitmap)}\n") } File.open("Diagnose.txt", "a") { |file| file.print("dispose: battler #{@battler ? @battler.name : "nil"}, @used_bitmap.include?(@spr_icon.bitmap) #{@used_bitmap.include?(@spr_icon.bitmap)}\n") } File.open("Diagnose.txt", "a") { |file| file.print("dispose: battler #{@battler ? @battler.name : "nil"}, @used_bitmap.include?(@balloon_sprite.bitmap) #{@used_bitmap.include?(@balloon_sprite.bitmap)}\n") } if @balloon_sprite tsbs_dispose dispose_bitmaps File.open("Diagnose.txt", "a") { |file| file.print("Pre dispose @anim_state: battler #{@battler ? @battler.name : "nil"}, disposed?: #{@anim_state.bitmap ? @anim_state.bitmap.disposed? : "nil"}, bitmap: #{@anim_state.bitmap}\n") } @anim_state.dispose File.open("Diagnose.txt", "a") { |file| file.print("Post dispose @anim_state: battler #{@battler ? @battler.name : "nil"}, disposed?: #{@anim_state.bitmap ? @anim_state.bitmap.disposed? : "nil"}, bitmap: #{@anim_state.bitmap}\n") } File.open("Diagnose.txt", "a") { |file| file.print("Pre dispose @anim_guard: battler #{@battler ? @battler.name : "nil"}, disposed?: #{@anim_guard.bitmap ? @anim_guard.bitmap.disposed? : "nil"}, bitmap: #{@anim_guard.bitmap}\n") } @anim_guard.dispose File.open("Diagnose.txt", "a") { |file| file.print("Post dispose @anim_guard: battler #{@battler ? @battler.name : "nil"}, disposed?: #{@anim_guard.bitmap ? @anim_guard.bitmap.disposed? : "nil"}, bitmap: #{@anim_guard.bitmap}\n") } File.open("Diagnose.txt", "a") { |file| file.print("Pre dispose @shadow: battler #{@battler ? @battler.name : "nil"}, disposed?: #{@shadow.bitmap ? @shadow.bitmap.disposed? : "nil"}, bitmap: #{@shadow.bitmap}\n") } @shadow.dispose File.open("Diagnose.txt", "a") { |file| file.print("Post dispose @shadow: battler #{@battler ? @battler.name : "nil"}, disposed?: #{@shadow.bitmap ? @shadow.bitmap.disposed? : "nil"}, bitmap: #{@shadow.bitmap}\n") } File.open("Diagnose.txt", "a") { |file| file.print("Pre dispose @spr_icon: battler #{@battler ? @battler.name : "nil"}, disposed?: #{@spr_icon.bitmap ? @spr_icon.bitmap.disposed? : "nil"}, bitmap: #{@spr_icon.bitmap}\n") } @spr_icon.dispose File.open("Diagnose.txt", "a") { |file| file.print("Post dispose @spr_icon: battler #{@battler ? @battler.name : "nil"}, disposed?: #{@spr_icon.bitmap ? @spr_icon.bitmap.disposed? : "nil"}, bitmap: #{@spr_icon.bitmap}\n") } File.open("Diagnose.txt", "a") { |file| file.print("Pre dispose @balloon_sprite: battler #{@battler ? @battler.name : "nil"}, disposed?: #{@balloon_sprite.bitmap ? @balloon_sprite.bitmap.disposed? : "nil"}, bitmap: #{@balloon_sprite.bitmap}\n") } if @balloon_sprite @balloon_sprite.dispose if @balloon_sprite File.open("Diagnose.txt", "a") { |file| file.print("Post dispose @balloon_sprite: battler #{@battler ? @battler.name : "nil"}, disposed?: #{@balloon_sprite.bitmap ? @balloon_sprite.bitmap.disposed? : "nil"}, bitmap: #{@balloon_sprite.bitmap}\n") } if @balloon_sprite end # -------------------------------------------------------------------------- # Alias method : dispose # -------------------------------------------------------------------------- def dispose_bitmaps File.open("Diagnose.txt", "a") { |file| file.print("Pre dispose_bitmaps @used_bitmap: battler #{@battler ? @battler.name : "nil"}, bitmaps: #{@used_bitmap.compact}\n") } @used_bitmap.compact.each do |bmp| File.open("Diagnose.txt", "a") { |file| file.print("Pre dispose_bitmaps: battler #{@battler ? @battler.name : "nil"}, disposed?: #{bmp ? bmp.disposed? : "nil"}, bitmap: #{bmp}\n") } bmp.dispose unless bmp.disposed? File.open("Diagnose.txt", "a") { |file| file.print("Post dispose_bitmaps: battler #{@battler ? @battler.name : "nil"}, disposed?: #{bmp ? bmp.disposed? : "nil"}, bitmap: #{bmp}\n") } end File.open("Diagnose.txt", "a") { |file| file.print("Post dispose_bitmaps @used_bitmap: battler #{@battler ? @battler.name : "nil"}, bitmaps: #{@used_bitmap.compact}\n") } end
I've tested for 3 cases:

Case 1 - ▼Killozapit - Cache Back enabled with KEEP_DISPOSED_BITMAPS = true

Case 2 - ▼Killozapit - Cache Back enabled with KEEP_DISPOSED_BITMAPS = false

Case 3 - ▼Killozapit - Cache Back disabled

The results, which combines the Diagnose.txt logs and gobj.txt logs, are in the attached "3 Cases.rar".

My hypothesis is that, there are something wrong with dispose under Bitmap, causing the bitmaps to not be disposed even when they're supposed to be.

As the project concerned creates lots of new bitmap instances during battles, the longer a battle, the more bitmap instances will be there before that battle ends, causing more and more memory consumption, eventually leading to this issue.

Upon further investigations, I'm pretty sure that ▼Killozapit - Cache Back is a root cause, but I still suspect there are some other undiscovered ones. My wild guess is that the below of ▼Implementation v1.4 can be another root cause(Line 4472 - 4489):

Spoiler
# -------------------------------------------------------------------------- # Alias method : bitmap= # -------------------------------------------------------------------------- alias tsbs_bitmap= bitmap= def bitmap=(bmp) self.tsbs_bitmap = bmp @used_bitmap.push(bmp) @used_bitmap.uniq! return unless @battler && @battler.data_battler.use_sprite && bitmap wr = bitmap.width / self.class::MaxCol hr = bitmap.height / self.class::MaxRow yr = 0 xr = 0 src_rect.set(xr,yr,wr,hr) src_rect.y = (@anim_cell / MaxCol) * height src_rect.x = (@anim_cell % MaxCol) * width self.mirror = @battler.battler_flip end
I don't know how that original bitmap= works, but it seems to me that the old bitmap will be no longer referenced as thus "garbage collected". If that's the case, then those bitmaps that are supposed to be gone will remain there instead, as they'll be referenced by @used_bitmap, which will only dispose all its stored bitmaps at the end of a battle.

As I've checked that @used_bitmap is only used to store all used bitmaps and disposes them all at the end of a battle, I think it can be safely removed, if I do get how the original bitmap= works.

3 Cases.rar
I'm giving out another reward for fixing the issue

as you may know, my game start with logos

the first logo stating that the game using Theo TSBS will be added with the name of the one fixing that lag.

names of scripters who also majorly contributed(im looking at you, DoubleX), will also have their names added.

With DoubleX help, the lag is less severe but still rampant, especially with multiattack sequences.
After more data mining, it turns out your project has lots of undisposed objects upon battle end that are linked to Scene_Battle.

I used this modified version of DoubleX RMVXA Object Trace:

Spoiler
#==============================================================================|# ** Script Info |#------------------------------------------------------------------------------|# * Script Name |# DoubleX RMVXA Object Trace |#------------------------------------------------------------------------------|# * Functions |# Traces all objects belonging to a queried class linked to a queried object|# Designed as a bug diagnosis tool used by scripters with debug experience |#------------------------------------------------------------------------------|# * Example |# obj.inspect |# - http://pastebin.com/kb1q1Dru |# obj.trace_obj(Proc); obj.obj_trace[Proc].inspect |# - http://pastebin.com/PZ4KNbHv |#------------------------------------------------------------------------------|# * Terms Of Use |# You shall keep this script's Script Info part's contents intact |# You shalln't claim that this script is written by anyone other than |# DoubleX or his aliases |# None of the above applies to DoubleX or his aliases |#------------------------------------------------------------------------------|# * Prerequisites |# Abilities: |# 1. Basic knowledge of inspecting objects in Ruby |# 2. Some RGSS3 scripting proficiency to fully utilize this script |#------------------------------------------------------------------------------|# * Instructions |# 1. Open the script editor and put this script into an open slot between |# Materials and Main, save to take effect. |#------------------------------------------------------------------------------|# * Links |# Script Usage 101: |# 1. forums.rpgmakerweb.com/index.php?/topic/32752-rmvxa-script-usage-101/ |# 2. rpgmakervxace.net/topic/27475-rmvxa-script-usage-101/ |# This script: |# 1. http://pastebin.com/pySjrKvh |#------------------------------------------------------------------------------|# * Author |# DoubleX |#------------------------------------------------------------------------------|# * Changelog |# v1.01b(GMT 1300 13-7-2015): |# 1. Fixed not tracing klass linked to klass linked to queried object bug |# 2. Fixed some Script Call Info and Implementation documentation typos |# 3. Added more info in Prerequisites and Script Call Info |# 4. Increased this script's compactness |# v1.01a(GMT 1300 6-7-2015): |# 1. Instance methods can be traced as well |# v1.00b(GMT 0800 1-7-2015): |# 1. Fixed object having Range and/or Structs not tracing klass properly bug|# v1.00a(GMT 1200 27-6-2015): |# 1. 1st version of this script finished |#==============================================================================|#==============================================================================|# ** Script Call Info |# A path in the object trace will stop if it would otherwise become cyclic |#------------------------------------------------------------------------------|# * Object manipulations |# 1. trace_obj(klass) |# - Traces all objects belonging to klass linked to this object |# 2. obj_trace[klass] |# - Returns the trace of objects belonging to klass linked to this object|# 3. (v1.01a+)trace_idef(klass) |# - Traces all instance methods linked to this object |# 4. (v1.01a+)idef_trace[klass] |# - Returns the trace of all instance methods linked to this object |#==============================================================================|($doublex_rmvxa ||= {})[😮bj_Trace] = "v1.01b"#==============================================================================|# ** Script Implementations |# You need not edit this part as it's about how this script works |#------------------------------------------------------------------------------|# * Script Support Info: |# 1. Prerequisites |# - Solid understanding of inspecting objects in Ruby |# - Decent RGSS3 scripting proficiency to fully comprehend this script |# 2. Method documentation |# - The 1st part informs which version rewritten, aliased or created this|# method |# - The 2nd part informs whether the method's rewritten, aliased or new |# - The 3rd part describes what the method does for new methods only |# - The 4th part describes what the arguments of the method are |# - The 5th part describes how this method works for new methods only, |# and describes the parts added, removed or rewritten for rewritten or |# aliased methods only |# Example: |# #--------------------------------------------------------------------------| |# # (Version X+)Rewrite/Alias/New method: def_name | |# # - What this method does | |# #--------------------------------------------------------------------------| |# # *argv: What these variables are |# # &argb: What this block is |# def def_name(*argv, &argb) |# # Added/Removed/Rewritten to does something/How this method works |# def_name_code |# # |# end # def_name |#------------------------------------------------------------------------------|#------------------------------------------------------------------------------|# * Edit class: Object |#------------------------------------------------------------------------------|class Object #----------------------------------------------------------------------------| # New public instance variables | #----------------------------------------------------------------------------| attr_reader :idef_trace # (v1.01a+)The trace of all linked instance methods attr_reader 😮bj_trace # The traces of all objects linked to this object # (v1.01a+)The list of symbols of all instance variables added by this script OBJ_TRACE_IVAR = ["@idef_trace".to_sym, "@obj_trace".to_sym] #----------------------------------------------------------------------------| # (v1.01a+)New method: trace_idef | # - Traces all instance methods linked to this object | #----------------------------------------------------------------------------| def trace_idef # Embeds the instance method traces of all objects linking to this object @idef_trace ? return : @idef_trace = {} trace_instance_idef return trace_array_idef if is_a?(Array) return trace_hash_idef if is_a?(Hash) return trace_range_idef if is_a?(Range) trace_struct_idef if is_a?(Struct) # end # trace_idef #----------------------------------------------------------------------------| # (v1.01a+)New method: trace_instance_idef | # - Traces all linked instance variables having instance methods | #----------------------------------------------------------------------------| def trace_instance_idef # Embeds the instance method traces of all linked instance variables (instance_variables - OBJ_TRACE_IVAR).each { |ivar| trace_all_idef(ivar, instance_variable_get(ivar)) } # end # trace_instance_idef #----------------------------------------------------------------------------| # (v1.01a+)New method: trace_array_idef | # - Traces all arrays linked to this object | #----------------------------------------------------------------------------| def trace_array_idef # Embeds the instance method traces of all arrays linking to this object each_with_index { |val, index| trace_all_idef(index, val) } # end # trace_array_idef #----------------------------------------------------------------------------| # (v1.01a+)New method: trace_hash_idef | # - Traces all hashes linked to this object | #----------------------------------------------------------------------------| def trace_hash_idef # Embeds the instance method traces of all hashes linking to this object each { |key, val| trace_all_idef(key, val) } # end # trace_hash_idef #----------------------------------------------------------------------------| # (v1.01a+)New method: trace_range_idef | # - Traces all ranges linked to this object | #----------------------------------------------------------------------------| def trace_range_idef # Embeds the instance method traces of all ranges linking to this object index = -1 each { |val| trace_all_idef(index += 1, val) } # end # trace_range_idef #----------------------------------------------------------------------------| # (v1.01a+)New method: trace_struct_idef | # - Traces all structs linked to this object | #----------------------------------------------------------------------------| def trace_struct_idef # Embeds the instance method traces of all structs linking to this object each_pair { |key, val| trace_all_idef(key, val) } # end # trace_struct_idef #----------------------------------------------------------------------------| # (v1.01a+)New method: trace_all_idef | # - Embeds all non empty instance method traces linking to this object | #----------------------------------------------------------------------------| # iks: The index/key/symbol of the object trace # val: The object to be traced def trace_all_idef(iks, val) # Marks the existence of instance methods or embeds a linked non empty trace unless (idefs = val.instance_methods).empty? @idef_trace[iks] = [idefs] end val.trace_idef return if (trace = val.idef_trace).empty? (@obj_trace[iks] ||= []) << trace # end # trace_all_idef #----------------------------------------------------------------------------| # New method: trace_obj | # - Traces all objects belonging to klass linked to this object | #----------------------------------------------------------------------------| # klass: The class of all objects to be traced def trace_obj(klass) # Embeds the klass traces of all objects linking to this object (@obj_trace ||= {})[klass] ? return : @obj_trace[klass] = {} trace_instance_obj(klass) return trace_array_obj(klass) if is_a?(Array) return trace_hash_obj(klass) if is_a?(Hash) return trace_range_obj(klass) if is_a?(Range) trace_struct_obj(klass) if is_a?(Struct) # end # trace_obj #----------------------------------------------------------------------------| # New method: trace_instance_obj | # - Traces all instance variables belonging to klass linked to this object | #----------------------------------------------------------------------------| # klass: The class of all objects to be traced def trace_instance_obj(klass) # Embeds the klass traces of all instance variables linking to this object (instance_variables - OBJ_TRACE_IVAR).each { |ivar| trace_all_obj(klass, ivar, instance_variable_get(ivar)) } # end # trace_instance_obj #----------------------------------------------------------------------------| # New method: trace_array_obj | # - Traces all arrays linked to this object | #----------------------------------------------------------------------------| # klass: The class of all objects to be traced def trace_array_obj(klass) # Embeds the klass traces of all arrays linking to this object each_with_index { |val, index| trace_all_obj(klass, index, val) } # end # trace_array_obj #----------------------------------------------------------------------------| # New method: trace_hash_obj | # - Traces all hashes linked to this object | #----------------------------------------------------------------------------| # klass: The class of all objects to be traced def trace_hash_obj(klass) # Embeds the klass traces of all hashes linking to this object each { |key, val| trace_all_obj(klass, key, val) } # end # trace_hash_obj #----------------------------------------------------------------------------| # (v1.00b+)New method: trace_range_obj | # - Traces all ranges linked to this object | #----------------------------------------------------------------------------| # klass: The class of all objects to be traced def trace_range_obj(klass) # Embeds the klass traces of all ranges linking to this object index = -1 each { |val| trace_all_obj(klass, index += 1, val) } # end # trace_range_obj #----------------------------------------------------------------------------| # (v1.00b+)New method: trace_struct_obj | # - Traces all structs linked to this object | #----------------------------------------------------------------------------| # klass: The class of all objects to be traced def trace_struct_obj(klass) # Embeds the klass traces of all structs linking to this object each_pair { |key, val| trace_all_obj(klass, key, val) } # end # trace_struct_obj #----------------------------------------------------------------------------| # (v1.01a+)New method: trace_all_obj | # - Embeds all non empty klass traces linking to this object | #----------------------------------------------------------------------------| # klass: The class of all objects to be traced # iks: The index/key/symbol of the object trace # val: The object to be traced def trace_all_obj(klass, iks, val) # Marks the existence of a klass object or embeds a linked non empty trace if val.respond_to?(klass) @obj_trace[klass][iks] = ["#{val.class} #{klass}: false".to_sym] unless val.send(klass) end val.trace_obj(klass) return if (trace = val.obj_trace[klass]).empty? (@obj_trace[klass][iks] ||= []) << trace # end # trace_all_objend # Object#------------------------------------------------------------------------------|#==============================================================================|
This memory leak fix snippet(place it just above main):

Spoiler
class Sprite_Battler < Sprite_Base # Edit def initialize(*args) # Rewrite tsbs_init(*args) @balloon_duration = 0 # Removed to stop stored any used bitmap # @anim_state = Sprite_AnimState.new(self,viewport) @shadow = Sprite_BattlerShadow.new(self,viewport) @anim_guard = Sprite_AnimGuard.new(self,viewport) @spr_icon = Sprite_BattlerIcon.new(self,viewport) @anim_cell = -1 @anim_origin = Screen_Point.new end def bitmap=(bmp) # Rewrite self.tsbs_bitmap = bmp # Removed to stop stored any used bitmap # return unless @battler && @battler.data_battler.use_sprite && bitmap wr = bitmap.width / self.class::MaxCol hr = bitmap.height / self.class::MaxRow yr = 0 xr = 0 src_rect.set(xr,yr,wr,hr) src_rect.y = (@anim_cell / MaxCol) * height src_rect.x = (@anim_cell % MaxCol) * width self.mirror = @battler.battler_flip end # bitmap= def dispose # Rewrite tsbs_dispose # Rewritten @anim_state.dispose if @anim_state && !@anim_state.disposed? @anim_state = nil @anim_guard.dispose if @anim_guard && !@anim_guard.disposed? @anim_guard = nil @shadow.dispose if @shadow && [email protected]? @shadow = nil @spr_icon.dispose if @spr_icon && !@spr_icon.disposed? @spr_icon = nil dispose_balloon # end # dispose def dispose_balloon # Rewrite # Rewritten return unless @balloon_sprite @balloon_sprite.bitmap.dispose if @balloon_sprite.bitmap && !@balloon_sprite.bitmap.disposed? @balloon_sprite.dispose unless @balloon_sprite.disposed? @balloon_sprite = nil # end # dispose_balloonend # Sprite_Battlerclass Sprite_Projectile < Sprite_Base # Edit def dispose # New bitmap.dispose if bitmap && !bitmap.disposed? super end # disposeend # Sprite_Projectileclass Sprite_BattlerShadow < Sprite # Edit def dispose # New bitmap.dispose if bitmap && !bitmap.disposed? super end # disposeend # Sprite_BattlerShadow # Editclass Sprite_BattlerIcon < Sprite_Base # Edit def dispose # New bitmap.dispose if bitmap && !bitmap.disposed? super end # disposeend # Sprite_BattlerIconclass Sprite_BattleCutin < Sprite # Edit def dispose # New bitmap.dispose if bitmap && !bitmap.disposed? super end # disposeend # Sprite_BattleCutinclass Battle_Plane < Plane # Edit def dispose # New bitmap.dispose if bitmap && !bitmap.disposed? super end # disposeend # Battle_Planeclass Bonus_Gauge # Edit alias dispose_memory_leak_fix dispose def dispose dispose_memory_leak_fix # Added to dispose all the undisposed bitmaps @bg_image.dispose if @bg_image @bonus_icons_image.dispose if @bonus_icons_image # end # disposeend # Bonus_Gaugeclass Window_ATS_Name < Window_Base # Edit def dispose # New @current_windowskin.dispose if @current_windowskin super end # disposeend # Window_ATS_Nameclass Window_Message < Window_Base # Edit def dispose # New @atsmo_old_windowskin.dispose if @atsmo_old_windowskin super end # disposeend # Window_Messageclass Window_MessageLog < Window_Selectable # Edit def dispose # New if @back_sprite @back_sprite.bitmap.dispose if @back_sprite.bitmap @back_sprite.dispose end super end # disposeend # Window_MessageLog
This diagnose snippet(place it just above main):

Spoiler
class Scene_Battle < Scene_Base alias terminate_diagnose terminate def terminate terminate_diagnose # Added to trace for any undisposed bitmap trace_obj🙂disposed?) File.open("Diagnose.txt", "a") { |file| file.print(obj_trace[:disposed?]) } # end # terminateend # Scene_Battle
And modified dispose under Window_Message of ▼Relocated Pause Graphic(line 38-45) to this:

Spoiler
#-------------------------------------------------------------------------- # * Alias: Dispose #-------------------------------------------------------------------------- alias move_pause_graphic_dispose dispose def dispose @pause_sprite.bitmap.dispose if @pause_sprite.bitmap @pause_sprite.dispose move_pause_graphic_dispose end
The below lists all undisposed objects upon battle end that are linked to Scene_Battle:

Spoiler
Code:
{:@spriteset=>[{:@sprite_scope=>[:"Sprite disposed?: false", {:@move_obj=>[{:@obj=>[:"Sprite disposed?: false"]}], :@obj=>[:"Sprite disposed?: false", {...}], :@circle=>[{:@obj=>[:"Sprite disposed?: false", {...}]}]}]}], :@message_window=>[{:@atsmo_all_windows=>[{0=>[:"Window_Gold disposed?: false", {:@move_obj=>[{:@obj=>[:"Window_Gold disposed?: false"]}], :@circle=>[{:@obj=>[:"Window_Gold disposed?: false", {...}]}]}], 1=>[:"Window_ChoiceList disposed?: false", {:@move_obj=>[{:@obj=>[:"Window_ChoiceList disposed?: false"]}], :@circle=>[{:@obj=>[:"Window_ChoiceList disposed?: false", {...}]}]}], 2=>[:"Window_NumberInput disposed?: false", {:@move_obj=>[{:@obj=>[:"Window_NumberInput disposed?: false"]}], :@circle=>[{:@obj=>[:"Window_NumberInput disposed?: false", {...}]}]}], 3=>[:"Window_KeyItem disposed?: false", {:@move_obj=>[{:@obj=>[:"Window_KeyItem disposed?: false"]}], :@circle=>[{:@obj=>[:"Window_KeyItem disposed?: false", {...}]}]}], 4=>[:"Window_ATS_Name disposed?: false", {:@move_obj=>[{:@obj=>[:"Window_ATS_Name disposed?: false"]}], :@circle=>[{:@obj=>[:"Window_ATS_Name disposed?: false", {...}]}]}]}], :@move_obj=>[{:@obj=>[{...}]}], :@circle=>[{:@obj=>[{...}]}], :@gold_window=>[:"Window_Gold disposed?: false", {:@move_obj=>[{:@obj=>[:"Window_Gold disposed?: false"]}], :@circle=>[{:@obj=>[:"Window_Gold disposed?: false", {...}]}]}], :@choice_window=>[:"Window_ChoiceList disposed?: false", {:@move_obj=>[{:@obj=>[:"Window_ChoiceList disposed?: false"]}], :@circle=>[{:@obj=>[:"Window_ChoiceList disposed?: false", {...}]}]}], :@number_window=>[:"Window_NumberInput disposed?: false", {:@move_obj=>[{:@obj=>[:"Window_NumberInput disposed?: false"]}], :@circle=>[{:@obj=>[:"Window_NumberInput disposed?: false", {...}]}]}], :@item_window=>[:"Window_KeyItem disposed?: false", {:@move_obj=>[{:@obj=>[:"Window_KeyItem disposed?: false"]}], :@circle=>[{:@obj=>[:"Window_KeyItem disposed?: false", {...}]}]}], :@atsmo_name_window=>[:"Window_ATS_Name disposed?: false", {:@move_obj=>[{:@obj=>[:"Window_ATS_Name disposed?: false"]}], :@circle=>[{:@obj=>[:"Window_ATS_Name disposed?: false", {...}]}]}], :@back_bitmap=>[:"Bitmap disposed?: false"], :@back_sprite=>[:"Sprite disposed?: false", {:@move_obj=>[{:@obj=>[:"Sprite disposed?: false"]}], :@obj=>[:"Sprite disposed?: false", {...}], :@circle=>[{:@obj=>[:"Sprite disposed?: false", {...}]}]}], :@pause_sprite=>[:"Sprite disposed?: false", {:@move_obj=>[{:@obj=>[:"Sprite disposed?: false"]}], :@obj=>[:"Sprite disposed?: false", {...}], :@circle=>[{:@obj=>[:"Sprite disposed?: false", {...}]}]}]}], :@damage=>[{:@hp_barrier_text=>[:"DamageResult disposed?: false", {:@move_obj=>[{:@obj=>[:"DamageResult disposed?: false"]}], :@obj=>[:"DamageResult disposed?: false", {...}], :@circle=>[{:@obj=>[:"DamageResult disposed?: false", {...}]}]}], :@damage_text=>[:"Sprite disposed?: false", {:@move_obj=>[{:@obj=>[:"Sprite disposed?: false"]}], :@obj=>[:"Sprite disposed?: false", {...}], :@circle=>[{:@obj=>[:"Sprite disposed?: false", {...}]}]}], :@damage=>[:"DamageResult disposed?: false", {:@move_obj=>[{:@obj=>[:"DamageResult disposed?: false"]}], :@obj=>[:"DamageResult disposed?: false", {...}], :@circle=>[{:@obj=>[:"DamageResult disposed?: false", {...}]}]}], :@hit_text=>[:"Sprite disposed?: false", {:@move_obj=>[{:@obj=>[:"Sprite disposed?: false"]}], :@obj=>[:"Sprite disposed?: false", {...}], :@circle=>[{:@obj=>[:"Sprite disposed?: false", {...}]}]}], :@hit=>[:"DamageResult disposed?: false", {:@move_obj=>[{:@obj=>[:"DamageResult disposed?: false"]}], :@obj=>[:"DamageResult disposed?: false", {...}], :@circle=>[{:@obj=>[:"DamageResult disposed?: false", {...}]}]}], :@result_text=>[:"DamageResult disposed?: false", {:@move_obj=>[{:@obj=>[:"DamageResult disposed?: false"]}], :@obj=>[:"DamageResult disposed?: false", {...}], :@circle=>[{:@obj=>[:"DamageResult disposed?: false", {...}]}]}]}], :@windows=>[{0=>[{:@atsmo_all_windows=>[{0=>[:"Window_Gold disposed?: false", {:@move_obj=>[{:@obj=>[:"Window_Gold disposed?: false"]}], :@circle=>[{:@obj=>[:"Window_Gold disposed?: false", {...}]}]}], 1=>[:"Window_ChoiceList disposed?: false", {:@move_obj=>[{:@obj=>[:"Window_ChoiceList disposed?: false"]}], :@circle=>[{:@obj=>[:"Window_ChoiceList disposed?: false", {...}]}]}], 2=>[:"Window_NumberInput disposed?: false", {:@move_obj=>[{:@obj=>[:"Window_NumberInput disposed?: false"]}], :@circle=>[{:@obj=>[:"Window_NumberInput disposed?: false", {...}]}]}], 3=>[:"Window_KeyItem disposed?: false", {:@move_obj=>[{:@obj=>[:"Window_KeyItem disposed?: false"]}], :@circle=>[{:@obj=>[:"Window_KeyItem disposed?: false", {...}]}]}], 4=>[:"Window_ATS_Name disposed?: false", {:@move_obj=>[{:@obj=>[:"Window_ATS_Name disposed?: false"]}], :@circle=>[{:@obj=>[:"Window_ATS_Name disposed?: false", {...}]}]}]}], :@move_obj=>[{:@obj=>[{...}]}], :@circle=>[{:@obj=>[{...}]}], :@gold_window=>[:"Window_Gold disposed?: false", {:@move_obj=>[{:@obj=>[:"Window_Gold disposed?: false"]}], :@circle=>[{:@obj=>[:"Window_Gold disposed?: false", {...}]}]}], :@choice_window=>[:"Window_ChoiceList disposed?: false", {:@move_obj=>[{:@obj=>[:"Window_ChoiceList disposed?: false"]}], :@circle=>[{:@obj=>[:"Window_ChoiceList disposed?: false", {...}]}]}], :@number_window=>[:"Window_NumberInput disposed?: false", {:@move_obj=>[{:@obj=>[:"Window_NumberInput disposed?: false"]}], :@circle=>[{:@obj=>[:"Window_NumberInput disposed?: false", {...}]}]}], :@item_window=>[:"Window_KeyItem disposed?: false", {:@move_obj=>[{:@obj=>[:"Window_KeyItem disposed?: false"]}], :@circle=>[{:@obj=>[:"Window_KeyItem disposed?: false", {...}]}]}], :@atsmo_name_window=>[:"Window_ATS_Name disposed?: false", {:@move_obj=>[{:@obj=>[:"Window_ATS_Name disposed?: false"]}], :@circle=>[{:@obj=>[:"Window_ATS_Name disposed?: false", {...}]}]}], :@back_bitmap=>[:"Bitmap disposed?: false"], :@back_sprite=>[:"Sprite disposed?: false", {:@move_obj=>[{:@obj=>[:"Sprite disposed?: false"]}], :@obj=>[:"Sprite disposed?: false", {...}], :@circle=>[{:@obj=>[:"Sprite disposed?: false", {...}]}]}], :@pause_sprite=>[:"Sprite disposed?: false", {:@move_obj=>[{:@obj=>[:"Sprite disposed?: false"]}], :@obj=>[:"Sprite disposed?: false", {...}], :@circle=>[{:@obj=>[:"Sprite disposed?: false", {...}]}]}]}]}]}
I haven't scripted in a while, but doesn't this part

@used_bitmap.push(bmp)@used_bitmap.uniq!cause undisposed bitmaps, when they are removed from the array by "uniq!"?/edit: I see DoubleX replaced that part already.
Found 1 more root cause: TSBS simply created too many deep copies during battles.

I tried to log all the deep copies and it printed a txt with more than 91MB lol

I use this snippet to reduce the memory usage of the Game.exe upon battle end from roughly 190MB to roughly 170MB XD

Spoiler
Code:
#------------------------------------------------------------------------------|#  Alias method: copy                                                          |#------------------------------------------------------------------------------|alias tsbs_copy copydef copy(object)  # Rewritten to store the deep copy into the global deep copy container  $game_temp.deep_copy_container[object] ||= []  deep_copy = tsbs_copy(object)  $game_temp.deep_copy_container[object] << deep_copy  deep_copy  #end # copy#------------------------------------------------------------------------------|#  * Edit class: Game_Temp                                                     |#------------------------------------------------------------------------------|class Game_Temp  #----------------------------------------------------------------------------|  #  New public instance variable                                              |  #----------------------------------------------------------------------------|  attr_reader :deep_copy_container # The container of all deep copies made  #----------------------------------------------------------------------------|  #  Alias method: initialize                                                  |  #----------------------------------------------------------------------------|  alias tsbs_init_2 initialize  def initialize    tsbs_init_2    # Added to initialize the deep copy container as well    @deep_copy_container = {}    #  end # initializeend # Game_Tempclass Scene_Battle < Scene_Base  alias tsbs_terminate2 terminate  def terminate    tsbs_terminate2    # Added to clear all deep copies upon battle end    $game_temp.deep_copy_container.each_key { |obj|      $game_temp.deep_copy_container[obj] = nil    }    $game_temp.deep_copy_container.clear    #  end # terminateend # Scene_Battle
weird, my memory went up to 270k with that snippet or maybe its the other fixes l tried before

also one of the modifications made state counter and the mog cursor aoe arrow not working anymore

ill just restart again and try this snippet and hope it lower the lag a bit

Original thread: https://forums.rpgmakerweb.com/threads/weirdest-lag-issue-you-will-see-ever-need-help-fixing-it.44852/