Sarena

RPG Making since RM95!
Veteran
Joined
Oct 3, 2015
Messages
56
Reaction score
21
First Language
English
Primarily Uses
RMMZ
I noticed after testing my RMMZ game a bunch of times in a row that my CPU was at 100%, and that lots of instances of nwjs were open and taking up the majority of my memory. I had just been working in some Scripts that use arrays, so I was thinking that might have to do with it, so I figured I'd ask here.

Are there efficient ways to search for if something is causing a memory leak? I've looked on the Memory tab of the debug log, but I'm not sure how to efficiently read the data. I've seen the number raising to ~150-190 kB/s and in red, so I'm not sure if that is bad and might be causing this. So any insight on this would be helpful!
Memory.png

In addition, since I haven't used arrays a whole lot in my JavaScript experience, I wanted to see if anyone could spot anything wrong with my code that could be causing it to use up a lot of memory, or if there's a way to do this more efficiently that doesn't use as much memory.

Here's one of the arrays I have:
JavaScript:
let activeMission = $gameVariables.value(159);

activeMission.push("EscapeFromThePartyPlace"); // 1
activeMission.push("Channel6Acting"); // 2
activeMission.push("OutlawBarParty"); // 3

And then this one has a bit more code:
JavaScript:
let activeMission = $gameVariables.value(159);
let eventure = $gameVariables.value(117);
let failedMission = $gameVariables.value(161);
var index;
var removed;

if (activeMission.includes("EscapeFromThePartyPlace") && eventure != "Party Sanctuary") {
    failedMission.push("EscapeFromThePartyPlace");
    index = activeMission.indexOf("EscapeFromThePartyPlace");
    removed = activeMission.splice(index, 1);
}

I also have a few Conditional Branches that check for things like this:
JavaScript:
$gameVariables.value(159)[1] != undefined;

There are some more instances of this type of code throughout, but this is the main code that I added that I thought might be a contributor.
 

Zeriab

Huggins!
Veteran
Joined
Mar 20, 2012
Messages
1,309
Reaction score
1,513
First Language
English
Primarily Uses
Other
By the sound of your problem description your issue seems to be the 100% CPU.
I suggest you go to the performance and record a session where you play and hit 100% CPU. This will give you much more data on what costs performance-wise.
Keep your mind open and don't exclusively focus on memory leaks.

Good hunting!

*hugs*
- Zeriab
 

Nolonar

Veteran
Veteran
Joined
Feb 18, 2018
Messages
334
Reaction score
458
First Language
French, German
Primarily Uses
RMMZ
I'm not seeing sufficient evidence of a memory leak. 18 MB is not a lot, and neither is an increase of 156 kB/s.

In fact, there's no need to worry about memory usage rising. This is normal for JavaScript, which has no explicit memory management, and has to rely on a so-called "Garbage Collector" (GC) instead. As your game runs, its memory requirements will keep growing as the code requires more and more variables, then the GC will automatically scan the memory to find variables that are no longer accessible (no longer in use), and will set that memory free.

In an RPG Maker game, this may happen when your player teleports to another map. Since you're loading a different tileset, the variable holding the tileset image will now hold a different tileset image, losing any reference to the previous tileset data in the process. The GC will eventually come around, notice the old tileset data, and collect it to free the memory it's using. This doesn't happen instantly, and there's no way to predict when GC will run.

As a result you need to monitor your memory usage over a long period of time (which can be several minutes to a couple of hours), as your memory usage slowly increases, then suddenly drops, then slowly increases again, etc. If the memory usage trend increases (the maximum and minimum memory usage keeps growing with each GC run), you might have a memory leak. Otherwise you're safe.
 

ATT_Turan

Forewarner of the Black Wind
Veteran
Joined
Jul 2, 2014
Messages
3,154
Reaction score
1,865
First Language
English
Primarily Uses
RMMV
Just to add - it's not abnormal to see most of your CPU getting used, especially if you have several programs open and one is a video game. If it's consistently sitting at 100% for an extended period while you play, that might not be right, but it's not unusual for programs to use the resources available to them and occasionally peak that high.
 

Sarena

RPG Making since RM95!
Veteran
Joined
Oct 3, 2015
Messages
56
Reaction score
21
First Language
English
Primarily Uses
RMMZ
Thanks for the responses, everyone!

I noticed that when I'm regularly working in the editor, my CPU is around 2-4%, and when I playtest for the first time, it only goes up to about 8-10%. So it seems like it just builds up after closing and reopening playtests a bunch (which is how it got up to 100% last night). So it probably won't be a real issue in the end for anyone playing my game at least. It's just a slight inconvenience to have to completely close out of all of the nwjs processes and RPG Maker every so often when I'm playtesting and developing, which seems a little odd to me, since I haven't had this happen in the past before.

It's good to know that this sounds like it's mostly normal though. I have a pretty powerful PC with 16 GB of RAM, so I was just surprised to see so much of the CPU being used up by an RPG Maker game.
 

SeaPhoenix

Veteran
Veteran
Joined
May 14, 2015
Messages
324
Reaction score
416
First Language
English
Primarily Uses
RMMV
I've experienced this too when I playtest several times (multiple instances of nwjs remain open, even after the playtest has been closed), though it happens somewhat randomly and I cannot reproduce it reliably. I usually check my Task Manager once I hear my computer's fan being loud - it's not a big deal, but it's annoying. I've not experienced it with playing a deployed game so far, though.

It seems to be a bug that was reported back in May: https://forums.rpgmakerweb.com/index.php?threads/a-couple-of-bugs-version-1-2-1-steam.136906/

Are you using the standalone version or the Steam version, @Sarena? I'm using the Steam version and have considered trying the standalone version to see if the same problem occurs.
 

Sarena

RPG Making since RM95!
Veteran
Joined
Oct 3, 2015
Messages
56
Reaction score
21
First Language
English
Primarily Uses
RMMZ
Are you using the standalone version or the Steam version, @Sarena? I'm using the Steam version and have considered trying the standalone version to see if the same problem occurs.

I'm also using the Steam version, with my project on version 1.3.2 (most recent). But that's a good idea to try the standalone version to see if that still happens, thanks!

Glad to know it's not just me though! Hopefully they make a patch to fix it.
 

Tea's Jams

I'm human
Global Mod
Joined
Mar 28, 2017
Messages
1,192
Reaction score
2,822
First Language
English
Primarily Uses
RMMZ
If anyone experiencing this notices it again, can you try this to see if you're able to get an error report? I've been trying to nail this one down to replicate it.

1. Type event viewer in the search bar in the bottom left corner of your desktop. (Win 10)

2. Check to see if any errors have popped up mentioning MZ and if so, please copy the text of the error and share it either here, or in a DM to me.

If you share it here, put it in a spoiler since it might be a lot of text.

Also, if you could share exactly what you're doing when it happens that would be helpful. :LZSjoy:
 

Sarena

RPG Making since RM95!
Veteran
Joined
Oct 3, 2015
Messages
56
Reaction score
21
First Language
English
Primarily Uses
RMMZ
If anyone experiencing this notices it again, can you try this to see if you're able to get an error report? I've been trying to nail this one down to replicate it.

1. Type event viewer in the search bar in the bottom left corner of your desktop. (Win 10)

2. Check to see if any errors have popped up mentioning MZ and if so, please copy the text of the error and share it either here, or in a DM to me.

If you share it here, put it in a spoiler since it might be a lot of text.
I'll be sure to let you know if it happens to me again, thank you for the info on what to send! :)

Also, if you could share exactly what you're doing when it happens that would be helpful. :LZSjoy:

I was creating my own menu system that uses arrays (some of the code in my first post). This is basically just a few events on a map that the player is teleported to (the teleporting happens through the VisuStella MZ Main Menu Core). Here's a video of the types of things I was testing when I ran into this:


I'll keep you updated as I continue to test in the future though! Luckily it's only happened to me that one night, but if I notice it again, I'll be sure to post here or DM you.
 

Latest Threads

Latest Profile Posts

Hi everyone! Enjoying this nice long weekend. How are you all doing? :)
I just successfully tested having events check if specific actors are in a particular party slot and then changing image to match. This will let me make scenes take into account who is in the party at the time and arrange them accordingly - this is important since I'll have extra actors beyond current party. The script used is the same from MV and is compatible with my current core plugin setup in MZ. Thank goodness.
That awkward moment when you're talking about thinking about writing a limited shop stock plugin for MZ and then find out you already wrote one...last May. My memory is so bad.
When I open my project and I'm like, hell yeah.
Some drawings I made in Lapis, one day I intend to involve them in some RPG Maker project.
* maybe two wall frames
*or some sprite flower tiara, or maybe it inspires someone to do something.
bdd19b62e539d17b3b00cc3d63034f7d.jpg

fcca5c8471b34483da8e032cfe579275.jpg

Forum statistics

Threads
118,426
Messages
1,115,857
Members
155,377
Latest member
L4TNG
Top