Memory allocation / freeing / leaks / expanding universe
Moderators: Moderators for English X Forum, Scripting / Modding Moderators
- AtomicDryad
- Posts: 209
- Joined: Sat, 19. Jan 08, 01:04
Memory allocation / freeing / leaks / expanding universe
Recently my savegame has been growing (32 megs to 52 in 2 days, it was 13 megs 1 month ago...) and I've been experiencing more slowdown.
I've been trying to find out WTF is doing this, and I only have a few possible suspects:
New version of PM (things -really- started to slowdown after I started testing this) http://forum.egosoft.com/viewtopic.php?t=255379
STO (constant 2 ms while loop)
And last but hopefully least, my chat script. (800-1200ms while loop that re-reads a T file that -constantly- changes). http://forum.egosoft.com/viewtopic.php?t=275233
My chat script uses a frontend and a 'daemon' that runs on a station in null. When starting, the frontend creates a menu array, then starts the daemon, passing it the array as an argument. The daemon, in a while loop, reads the T file, parses it, and adjusts the array in the following fashion:
Truncates it via 'resize array'
append to array (stuff)
If the frontend isn't running, and a 'run in background' local variable is not set, the daemon does 'return null'. If the bg variable is set, the daemon sets an local variable = $menuarray, and continues functioning. A new frontend would thus read the local variable, set it null, and continue to function as the original.
I would assume resize array de-allocates the memory and thus any information that would be written to a savegame. I also hope that setting a global/local variable that's an array ptr = null (or a temporary script variable for that matter) would de-allocate memory.
I'm hoping that someone who definitively knows how the script engine works (perhaps an Egosoft dev) could confirm this. If it indeed does not then this is a big problem that's literally growing as I type.
If there are memalloc issues in regards to re-reading a T file that's constantly in flux, or the other methods I have described above, please let me know. The behavior of arrays=always pointers (even persistent variables) might lead to 'droppings' scattered about if a scripter isn't careful.
Also, does -removing- a script from the script dir terminate running instances on reload? And if so, does that clear any memory? Is there any way to dissect and inspect a savegame or the entire universe for that matter?
edit: Aha! For those who wonder, zcat X01.sav | strings |less is somewhat enlightening.
I've been trying to find out WTF is doing this, and I only have a few possible suspects:
New version of PM (things -really- started to slowdown after I started testing this) http://forum.egosoft.com/viewtopic.php?t=255379
STO (constant 2 ms while loop)
And last but hopefully least, my chat script. (800-1200ms while loop that re-reads a T file that -constantly- changes). http://forum.egosoft.com/viewtopic.php?t=275233
My chat script uses a frontend and a 'daemon' that runs on a station in null. When starting, the frontend creates a menu array, then starts the daemon, passing it the array as an argument. The daemon, in a while loop, reads the T file, parses it, and adjusts the array in the following fashion:
Truncates it via 'resize array'
append to array (stuff)
If the frontend isn't running, and a 'run in background' local variable is not set, the daemon does 'return null'. If the bg variable is set, the daemon sets an local variable = $menuarray, and continues functioning. A new frontend would thus read the local variable, set it null, and continue to function as the original.
I would assume resize array de-allocates the memory and thus any information that would be written to a savegame. I also hope that setting a global/local variable that's an array ptr = null (or a temporary script variable for that matter) would de-allocate memory.
I'm hoping that someone who definitively knows how the script engine works (perhaps an Egosoft dev) could confirm this. If it indeed does not then this is a big problem that's literally growing as I type.
If there are memalloc issues in regards to re-reading a T file that's constantly in flux, or the other methods I have described above, please let me know. The behavior of arrays=always pointers (even persistent variables) might lead to 'droppings' scattered about if a scripter isn't careful.
Also, does -removing- a script from the script dir terminate running instances on reload? And if so, does that clear any memory? Is there any way to dissect and inspect a savegame or the entire universe for that matter?
edit: Aha! For those who wonder, zcat X01.sav | strings |less is somewhat enlightening.
- AtomicDryad
- Posts: 209
- Joined: Sat, 19. Jan 08, 01:04
/d/games/x3tc/_user/save# zcat X01.sav|strings -n 8|grep plugin.FDN4.Station.Task |wc
2538870 11642631 193370483
192 megabytes, out of 235 megabytes (uncompressed|strings -n 8), is DEBUGSPEW(tm) from 'FDN' (another script). I just went on a station killing spree and my savegame is down to 18 megs again!
....now the question is, why didn't 'clear debug messages' work? I checked most of the stations for debug messages before killing them, maybe I missed one? Or is this a bug? o.o
*goes over things more slowly. Prevents Ore Mine L Alpha from destroying the universe.*
Would someone care to explain the structure of a savegame and tell me where to look for the object that lines of DEBUGSPEW(tm) resides on?
2538870 11642631 193370483
192 megabytes, out of 235 megabytes (uncompressed|strings -n 8), is DEBUGSPEW(tm) from 'FDN' (another script). I just went on a station killing spree and my savegame is down to 18 megs again!
....now the question is, why didn't 'clear debug messages' work? I checked most of the stations for debug messages before killing them, maybe I missed one? Or is this a bug? o.o
*goes over things more slowly. Prevents Ore Mine L Alpha from destroying the universe.*
Would someone care to explain the structure of a savegame and tell me where to look for the object that lines of DEBUGSPEW(tm) resides on?
- AtomicDryad
- Posts: 209
- Joined: Sat, 19. Jan 08, 01:04
-
- Posts: 2255
- Joined: Mon, 31. Oct 05, 08:44