Behind the Scenes Polishing

I'm currently approaching the end of development for my first RPG Maker project.
It's a ways off but still but close enough that I wanted to ask this question.

Being my first project it is full of unnecessary switches and variables. Things I started to put in but eventually
cut out. Instances where I found a solution other than a switch or a variable, but never deleted it. I know that
this takes up unnecessary space and can potentially affect performance.

I know that there is a menu to bring up the status of switches and values of variables. I'm wondering if there is also a way
to see if that switch/variable has even been used in game . A switch might say OFF or a variable might be set at 0, but it could
still have been used at a certain point. I have of course named all of them, but there are quite a few that are very similar in name and function.

Is there a simpler way than just individually going back through every single event to see if it has been used?
Or am I in for a long tedious clean up process?
I know that
this takes up unnecessary space
This is true but
can potentially affect performance.
this is most likely false. An unused variable is equal to 0 (which is a Fixnum in ruby). Even if you had around a hundred unused ones, they will still have little or no impact at all on the memory usage (the total space they take is still less than 10KB). On top of it, as long as they are unused, they do not require updates so they have no impact on performance as well. In VX Ace you have direct access to variables (T(N) = O(1)); it does not matter how many variables you have, you can still find the required one in the same amount of time. The same goes for switches.

Just think of how much space a single image takes into memory: a single image can take the same space as thousands of Fixnum instances.

Or am I in for a long tedious clean up process?
It is a very long and tedious process indeed. Let me explain with an example: if you have 100 variables and you did not use the ones from 40 to 80, you can reduce the number of variables from 100 to 60. However, this also means that the maximum ID for your variables is going to be 60. What happens to all those variables with ID greater than 60 (in my example those from 81 to 100)?

The answer is simple: you have to check your whole game and change your events so that whenever they use a variable whose ID is greater than 80, it uses a different variable instead.

Long story short: do not waste time doing that. It is not worth the effort if we talk about memory consumption, even less if we talk about performance.
you *could* (maybe, very *theoretically*) run a function to scan every single event in every single map, and tally up the calls to variables and switches.

they are printable to a file, and the events are readable in plain code form (as long as you don't have any non-editor-based events, AKA code-based events, that wouldn't be saved in each map).... the issue would be, what to do with the amount of data collected, and how to read it.
you *could* (maybe, very *theoretically*) run a function to scan every single event in every single map, and tally up the calls to variables and switches.
Yes, this approach is similar to the mark & sweep one that ruby uses to handle your memory. However, more than handling the information, the problem lies with editing every single event after finding which variable is unused, and even once that much is done, it would still have 0 effect on performance and a very limited effect on memory usage.

they are printable to a file, and the events are readable in plain code form (as long as you don't have any non-editor-based events, AKA code-based events, that wouldn't be saved in each map).... the issue would be, what to do with the amount of data collected, and how to read it.
You could theoretically check code-based events as well. Ruby is an interpreted language, if you do not call the eval method on script calls, they are just simple strings. You can use a Regex to store every variable and switch ID used in a script call, and you can theoretically do the same for scripts.

If the OP wants to do it, this is the way to go. Scan every event in every map with a function and print all the unused switches/variables ID on a file. You could write the function in a way that it prints the upper and lower limits of a batch of IDs if it finds contiguous unused variables, effectively increasing the readability of the said file. But once again...it takes a few hours to write something like this, and it has no effect on performance. I definitely think it is not worth the effort.
Thank you everyone for your input.
I will admit a lot of that did completely fly over my head.:dizzy:

What I did take away however, is that the unused switches and variables don't have as much of an effect as I thought they would.
So thank you for potentially saving me hours of unnecessary work.☺️

This thread can now be closed due to the issue being resolved.
Thanks again.
@Ragpuppy87 To Report a thread for closing you have to use the button 'Report' at the bottom of your post.
Thanks

Thread closed IgnoreMe

Original thread: https://forums.rpgmakerweb.com/threads/behind-the-scenes-polishing.110388/