Clear Memory WIP

Hey, I'm working on a Clear Memory plugin that uses Javascript. My goal is to clear much memory cache as possible as a way to prevent crashes and lag.

A script command should be called 'image.cache'.

JavaScript:
refresh.imagecache;
    scenes.graphics if (LS:1) equals false;

This is a work in progress and my first time making one from scratch. I'm seeking for script examples based on what I've described below:

Clear graphics and voices:
Option 1: Outside of current scene
Option 2: Local Switch 1 off. (LS:1 equals false).
Option 3: Temporary toggle switch to refresh graphics and voices. (Switch from On to Off, then back to On.)

You may include each option if you like? I really appreciate it.

Specific graphics:
Background
Picture
Character
Unused graphic files

The unused graphic files should be disabled since they create much more RAM for 1020p.

I don't know where else could I requested on. The resource request sub-forum has to do with graphics, not plugins.

EDIT: My computer has 8GB RAM in total. If my video game runs on 2GB RAM, then my computer has 6GB RAM left. I should've mention this before, but it completely slips my mind. I even got confused about Remaining RAM vs. RAM Usage Limit. Example: 6GB out of 8GB vs 2GB out of 8GB. I thought my computer is almost maxed out of RAM.
What actual problems have you encountered? The program - and your computer generally - is designed to use appropriate amounts of RAM and automatically purge items when necessary.

Are your games crashing because you run out of RAM?
It's not a problem, it's about making a plugin to prevent crashes from running out of RAM. I never got a crash on my computer, but I'm being cautious to not go over one GB RAM.
Why? 1 GB of RAM is a fraction of what any modern computer will have, and it's nowhere near the limit for the software (32-bit programs can access 4 GB ).

It just sounds like you're trying to solve a problem that doesn't exist.
When I said RAM, I mean RAM usage.
I know exactly what you meant, there was no confusion on my part. (in fact, I don't know what you think I could have been confused about 😛 )

The point stands that there's no technical reason for you to be doing this. You said
making a plugin to prevent crashes from running out of RAM.
when you have no reason to believe your game can or will do that. And, as I said, 1 GB of RAM usage is a fraction of what the program can handle.

But if you want to...good luck with your project.
It's not a problem, it's about making a plugin to prevent crashes from running out of RAM. I never got a crash on my computer, but I'm being cautious to not go over one GB RAM.
So first of all, let me explain why 1GB is way too little;
I am not familiar with VN Maker, but I assume, much like RMMV, it has been built with a 32bit instruction set. 32bit applications can, at most, only take advantage of 4gb of RAM. Assuming there hasn't been any page filing built into the software when going over 4 gigs, then the software may crash.

However, that brings me to the second point as to why this is a bad idea; that word I just used: page filing, or sometimes called virtual memory.
This basically will allocate a portion of the storage drive as "virtual RAM" but it's going to run as fast as your storage can.
To put this into perspective, RAM can run upwards to 100x faster than even a fast SSD.
When the system is page filing, it causes the software to perform poorly. It is, in essence, a fail-safe state.
By lowering the amount of available RAM, you are either going to force the software to enter page filing, or you are going to aggressively clear the memory cache which is going to cause other unwanted problems.

If you, or someone you know, is having crashes, this is the wrong approach to solve that issue.

I also would not trust someone to make code that addresses hardware utilization when they don't understand how hardware is utilized by the software. I'm just glad we aren't writing Assembly or something where inexperienced people would be able to have very high level access to directly address the hardware. There'd be a lot of innocent nudy devs just wanting to make their nudy games when some inexperienced dev with a big head thought their "optimizations" were actually causing the nudy dev's hardware to spontaneously explode.
Leave the nudy devs alone! Let them goon in peace!
I am planning to make a plugin that clears the memory cache in case of unwanted crashes and lags like Student Transfer, the game that lags on my computer.
why would you base your game's requirements on an entirely different game? Student Transfer isnt even VN Maker. Its RenPy, and you have to handle garbage collection yourself as the dev there. im fairly certain VNM does that for you automatically

Until youve seen your own game even remotely approach 4gb, theres no need to worry about it. at best, you reduce your ram usage from barely noticeable to barely noticeable and theres no lasting repercussions. anything less than best though...
Also - lag is typically not a symptom of too much RAM usage.

When a game tries to use more RAM than it can access on your system, it doesn't get slow, it crashes, as has already been mentioned several times.

Lag is more likely an issue to do with CPU usage or file loading.
If your computer doesn't have enough ram, I heard you can download more. Just download more ram. I do it all the time.
For some reason, you people aren't helping. Have you read a whole post on my thread, which is the first post. My computer runs at 8GB RAM.

I want to make sure a Visual Novel game run up to 1GB RAM usage.

JavaScript:
refresh.imagecache;
    scenes.graphics if (LS:1) equals false;

This is a work in progress and my first time making one from scratch. I'm seeking for script examples based on what I've described below:

Clear graphics and voices:
Option 1: Outside of current scene
Option 2: Local Switch 1 off. (LS:1 equals false).
Option 3: Temporary toggle switch to refresh graphics and voices. (Switch from On to Off, then back to On.)

You may include each option if you like? I really appreciate it.

Specific graphics:
Background
Picture
Character
Unused graphic files

The unused graphic files should be disabled since they create much more RAM for 1020p.

I don't know where else could I requested on. The resource request sub-forum has to do with graphics, not plugins.
For some reason, you people aren't helping.
We're not helping because you're not listening.

What you're saying you want is not how computers and computer software works.

Speaking for myself, I won't respond to the thread anymore, but you really shouldn't be trying to do this kind of thing if you don't understand fairly basic computer functionality.

Making a game that runs under 1 GB of RAM does not accomplish anything.

Between this and your thread about saving disk space by not naming variables (which also made no sense), you really might want to spend some time doing tutorials or something on how computer hardware and software works.
Sorry about that, I have no idea I wasn't listening.

Here's an example for a script made by Moghunter in the spoiler:
Spoiler: Clear Memory by Moghunter
Ruby:
# ================================================= =============================
# + + + MOG - Clear Memory (v1.0) (Memory Leak Solution) + + +
# ================================================= =============================
# By Moghunter
# [url]http://www.atelier-rgss.com[/url]
# ================================================= =============================
# The script clears the memory used by RpgMaker basically gives a reset
# The game without the player loses the game data.
# This script is geared for those who are having problem with overloading
# Memory Ram.
# ================================================= =============================
# USE
# ================================================= =============================
# Just use the code below to call via the command script.
#
# $ Game_system.clear_memory
#
# ================================================= =============================
# NOTE
# ================================================= =============================
# There will be a short break at the time the memory is cleared, so it is
# Advisable to clear the memory during a scene or when you teleport
# Between one map and another.
# ================================================= =============================


#===============================================================================
# ■ SceneManager
#===============================================================================
class << SceneManager

  #--------------------------------------------------------------------------
  # ● First Scene Class
  #-------------------------------------------------------------------------- 
  def first_scene_class
      $clear_memory ? Scene_Recover_Data : $BTEST ? Scene_Battle : Scene_Title
  end 
 
end

#===============================================================================
# ■ DataManager
#===============================================================================
class << DataManager
 
  #--------------------------------------------------------------------------
  # ● Save Game Temp
  #--------------------------------------------------------------------------
  def save_game_temp
      File.open("Quick_Save", "wb") do |file|
        $game_system.on_before_save
        Marshal.dump(make_save_header, file)
        Marshal.dump(make_save_contents, file)
      end
      return true
  end
 
  #--------------------------------------------------------------------------
  # ● Load Game Temp
  #--------------------------------------------------------------------------
  def load_game_temp
      File.open("Quick_Save", "rb") do |file|
        Marshal.load(file)
        extract_save_contents(Marshal.load(file))
        reload_map_if_updated
      end
      File.delete("Quick_Save") rescue nil
      return true
  end
 
end 

#===============================================================================
# ■ Game System
#===============================================================================
class Game_System
 
  #--------------------------------------------------------------------------
  # ● Clear_Memory
  #--------------------------------------------------------------------------       
  def clear_memory
      DataManager.save_game_temp
      reset = Win32API.new 'user32', 'keybd_event', %w(l l l l), ''
      reset.call(0x7B,0,0,0)
      sleep(0.1)
      $clear_memory = [RPG::BGM.last,RPG::BGS.last]
      reset.call(0x7B,0,2,0)
  end   
 
end 

#===============================================================================
# ■ Scene Recover Data
#===============================================================================
class Scene_Recover_Data
 
  #--------------------------------------------------------------------------
  # ● Main
  #--------------------------------------------------------------------------   
  def main
      SceneManager.clear
      DataManager.load_game_temp
      SceneManager.goto(Scene_Map)
      $clear_memory[0].replay rescue nil
      $clear_memory[1].replay rescue nil
      $clear_memory = nil
  end   
end

$mog_rgss3_clear_memory = true

If this example of a script made for RPGVX Ace still doesn't help. Then close this.
Here's an example for a script made by Moghunter in the spoiler:
I think everyone here understands what you're trying to do. They're just trying to explain that solving a problem you don't experience isn't a very useful thing to do - and certainly not worthwhile for others to use their time to help you solve a problem you don't even have.
Most Ram Usage come to overload if they run multiple programs.
aside from just a single program (like my system don't go over 100MB
if just 1 single program is running.

if a malware/virus boost your RAM way over, than clean your system as by
most modern pc's/laptops doesn't go over 1GB.

if it does on your system while making one, it's a developer issue.
so don't go into it if it does it job.

if you use VN maker, you can check it's core files or scripts whatever it used
and see how it is handled.

unlike MV/MZ if they use loads of pictures for visual aspect, they can easy
clear the memory on transfer with a scriptcall, if that also exist in VN,
use that and problem solved.

automatically do that is a mini function, so don't worry to much, most pc's
can handle it just fine.
VNM also has ways to clear memory like change scene.

Original thread: https://forums.rpgmakerweb.com/threads/clear-memory-wip.172468/