New to the forum? Say hello in this topic! Make sure to read the rules.
RULE NR 3 UPDATED: Don't hurt, harass or provoke other forum members or people.

memory leak with scripts

All bugs that's actually by design. This is to separate "solved bugs" from "by design".
Forum rules
By using the forum you agree to the following rules. For this forum you also need to follow these additional rules.
Post Reply
User avatar
JakSparro98
Superfighter
Superfighter
Posts: 256
Joined: Fri Jul 15, 2016 7:56 pm
Started SFD: PreAlpha 1.0.5
Location: Rome, Italy
Gender:
Age: 19

memory leak with scripts

Post by JakSparro98 » Sat Aug 06, 2016 7:17 pm

I was writing some script when I noticed that the memory used by SFD was weirdly too much.

When the game starts it has about 130 MB of ram in use, if you play official maps it won't rise more than 150 but I saw the game go over 300MB with one of my scripts, I also paid more attention by removing unused objects, pointers to old lists, ect.

I assume that the Garbage collection makes difficulties to understand what to recycle from my scripts, normally when I stop the simulation the ram is freed correctly, but not in this case.

I recreated my problem with this example, an array of objects (1500 elements), you have to push the button to print them to screen, while the cycle is running the program will hang and will resume after a couple of seconds, keep an eye on the task manager to see the amount of RAM, the used memory isn't released after the simulation end.
0 x

User avatar
Gurt
Lead Programmer
Lead Programmer
Posts: 901
Joined: Sun Feb 28, 2016 3:22 pm
Title: Lead programmer
Started SFD: Made it!
Location: Sweden
Gender:
Age: 27

Post by Gurt » Sat Aug 06, 2016 9:39 pm

Don't worry about it. The garbage collector can make your specific map raise the memory up to 800 MB on my computer if I keep pressing the button before the GC decides it's time to collect then it drops down again. If I force a call to GC.Collect() inside SFD in the SetText() function it stays stable but we will not call GC.Collect in runtime - better to let the GC decide when it's best to run and when to not let go of memory (but we do force a GC.Collect when closing a map for example).
Do not release your current test code in any public map as it will most likely congest the network and hang the server's CPU for some time. It builds a huuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuge string. Reminds me that I should probably limit maximum length the text.
0 x
Gurt

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest