Mysterious Crashes on Battle Start

Guys can you help? The game "sometimes" randomly crashes when a battle starts. It's always from the 2nd battle onwards, but it does so without any error message, it just shuts off, and I cannot pinpoint any specific conditions to replicate the bug regularly. I have no idea which of my scripts is responsible.

The Link to my Game's folder, includes the editor file: https://drive.google.com/drive/folders/1jBOnQuzJ2gUNOEKBE4X5tGxZ29yrMw2g
Any ideas would be welcome.
Moved to: RGSSx Script Support
Well, I can't say every single scripter will download your demo just because so why don't you tell us what custom scripts did you include in your game project?
I did download it and there were memory leaks. I gave solutions to the code.
New update to the memory leaks.
VE FOG was not disposing the fog after battle and was creating memory leaks.
I found that there was a typo. it had @fog_sprite where it should be @fog_sprites
But then it did not restore the map fog effects. so this is my solution.
Code:
class Scene_Battle < Scene_Base
  alias :terminate_battle_ve_fog_and_overlay :terminate
  def terminate
    terminate_battle_ve_fog_and_overlay
    $game_map.setup_fogs_effect
  end
end
class Spriteset_Battle
  def dispose_fogs
    if @fog_sprites
      $game_map.screen.fogs.clear
      @fog_sprites.compact.each {|sprite| sprite.dispose }
      @fog_sprites.clear
    end
  end
end
There were two other errors as well

Damage popup did not have a dispose.
Ruby:
class Scene_Battle
  def update_basic(*args)
    dam_pop_update(*args)
    @damage_popups.each do |popup| popup.update end
    @damage_popups.each_index do |index|
      if @damage_popups[index].done
        @damage_popups[index].bitmap.clear
        @damage_popups[index].dispose
        @damage_popups[index] = nil
      end
    end
    @damage_popups.compact!
  end
end

and the Bestiary did not have a dispose.
Ruby:
class Scene_Battle
  def dispose_instructions
    return if @info_instructions.nil?
    @info_instructions.bitmap.dispose
    @info_instructions.dispose
    @info_instructions = nil
  end
end

Last is a glitch with Vlue Popup. This helps with that.
The issue is that the popup stays in memory if the battle starts or the menu is called.
Best to dispose the popup under those conditions.
Of course others could cause the issue again but that can be avoided with good eventing.
Such as not calling a name input right after doing a popup.
Ruby:
class Scene_Map
  def pre_terminate
    popup_preterminate
    for i in [email hidden] - 1
      next if @popupwindow[i].nil? || @popupwindow[i].disposed?
      @popupwindow[i].visible = false unless @popupwindow[i].nil?
    end
  end
  alias r2_popup_pre_battle pre_battle_scene
  def pre_battle_scene
    @popupwindow.each_with_index do |pop, i|
      @popupwindow[i].dispose if !@popupwindow[i].nil?
      if @popupwindow[i].nil?
        Popup_Manager.queue.delete(i)
      end
    end
    r2_popup_pre_battle
  end
  alias r2_popup_call_menu call_menu
  def call_menu
    @popupwindow.each_with_index do |pop, i|
      @popupwindow[i].dispose if !@popupwindow[i].nil?
      if @popupwindow[i].nil?
        Popup_Manager.queue.delete(i)
      end
    end
    r2_popup_call_menu
  end
end

But there is still one I don't know how to fix.
Zeus Map Effects Line 22 where it creates the image. It is not disposed from what I can tell. But it may not be a problem. I don't know.

Original thread: https://forums.rpgmakerweb.com/threads/mysterious-crashes-on-battle-start.137683/