Finally got a little break from work, so let me try to answer/clarify things. Put your seatbelts on, this is another big one xD
For settlement enter events, yes a new one will be triggered. That's why you'll see throughout my code I use simple boolean locks to prevent that sort of code from running again if another instance is already happening. Also, the settlement enter event is actually provided by WorkshopFramework, and is designed to not repeat itself unless the player actually fully leaves the settlement - unlike vanilla location change events which can fire rapidly if the player is waffling on cell boundries.
Yesterday I was already half asleep and didn't read all of your posts correctly. I didn't even see you asking me how many plots I had until this morning. I have 29 plots in the triangle (assuming that storage is a sub plot class).
I saw your code for handling the boundaries and it is simple and efficient :D I also remember seeing your 'locks' in the code which totally freaked me out at first. Eventually, I noticed that they were just flow control bool flags
So, then although the GC was the one screaming in pain, that was just a symptom of the problem, not the root. Yesterday's fix seems to have solved it (GC wise), but we still need to find the root of the problem: why is that function being called so many times? And why does SS2 creates so many structures? This is results with 2.0.0L from yesterday, I'll try to do the test again today with M and I'm expecting fewer structures. But let's analyze the log anyway:
When I first loaded the 'problematic' save, SS2 and workshop framework created 223.000 structures between 16:33:02:489 and 16:33:05:531, so little over 3 seconds. It seems weird to me that SS2 needs so many structures on the game load. Anyway, most of them are released immediately after the game load, so, theoretically, the only impact of this is on the loading time. Now for the stacks. Unfortunately, workshopframework and SS2 won't tell me much about the structs created on the loading process, just that it is a world object and give its id:
[16:33:09:405 TID 16032] About to destroy a struct:
[16:33:09:405 TID 16032] workshopframework:library:datastructures#worldobject 0x0000018837183880
[16:33:09:405 TID 16032] [fAngleY = 0.000000, fExtraDataFlag = 0.000000, ObjectForm = None, fPosZ = 0.000000, fAngleX = 0.000000, fAngleZ = 0.000000, bForceStatic = False, fScale = 1.000000, iFormID = -1, fPosY = 0.000000, fPosX = 0.000000, sPluginName = ""]
[16:33:09:405 TID 16032]
info: Object creation site
...
[16:33:10:856 TID 16032] About to destroy a struct:
[16:33:10:856 TID 16032] simsettlementsv2:datastructures#stageitemstruct 0x0000018839ED0D20
[16:33:10:856 TID 16032] [iStageNum = 1, sLabel = "Locker03Books03", iStageEnd = -1, StageItemDetails = None, iOwnerNumber = 0]
[16:33:10:856 TID 16032]
info: Object creation site
At this point, I'm at line 2.078.590 of the log, when the GC gets its first breathing room. For 13 secs it does nothing until it starts creating more structures again.
[16:33:10:856 TID 16032] Released an object: 0x0000018839ED7560 Handle: 0x0000FFFF0D017261
[16:33:10:856 TID 16032] [Weapon < (0D017261)>]
[16:33:23:605 TID 16032] Created a struct workshopframework:library:datastructures#worldobject 0x000001883B3F1C00
[16:33:23:605 TID 16032] Created a struct workshopframework:library:datastructures#worldobject 0x000001883B3F1B20
[16:33:23:605 TID 16032] Created a struct simsettlementsv2:datastructures#stageitemstruct 0x00000188385E99D0
For the next ~450.000 lines (till line 2.527.969) SS2 and WF created as many objects again. Then it destroys them again, until line 4.105.790. A total of 1min has passed since the log started. I'm still assuming all of this is in the loading process.
I believe the following lines are from when I opened the workshop to build the container:
[16:33:39:575 TID 11648] Created a struct UI#MenuData 0x000001883AE8F320
[16:33:39:702 TID 16148] Created a struct hudframework#widgetmessage 0x000001883AEDEA20
[16:33:39:986 TID 11648] Created a struct fallout:overlays:client#opencloseeventargs 0x0000018831D1DB00
If that's correct, then this is when I closed the workshop:
[16:34:02:986 TID 16032] About to destroy a struct:
[16:34:02:986 TID 16032] fallout:overlays:client#opencloseeventargs 0x0000018831D1DB00
[16:34:02:986 TID 16032] [opening = True]
[16:34:02:986 TID 16032]
Between the call where I opened the workshop and where the save started, there are exactly 6438 lines of SS2 creating subplots structs to update the Hud. At 16:34:04:669 the GC starts cleaning up the structs created for the hud. This time the process was much slower, this was when it was actually saving. It took near 30min to clear GC and finish the saving process. During this time, 10034 structures created by GetPlotSubClasses were destroyed. The stacks show several paths, all coming from OnTimer() events:
290 came from simplot.OnTimer(): 290
stack:
[SS2_PlotManager (0D00EB47)].simsettlementsv2:quests:plotmanager.GetPlotSubClasses() - "C:\Program Files (x86)\Steam\steamapps\common\CC-F\Data\Scripts\Source\User\SimSettlementsV2\Quests\PlotManager.psc" Line 1019
[ (FF0034FD)].simsettlementsv2:objectreferences:simplot.GetBuildingClass() - "C:\Program Files (x86)\Steam\steamapps\common\CC-F\Data\Scripts\Source\User\SimSettlementsV2\ObjectReferences\SimPlot.psc" Line 8068
[ (FF0034FD)].simsettlementsv2:objectreferences:simplot.PlotRequiresPower() - "C:\Program Files (x86)\Steam\steamapps\common\CC-F\Data\Scripts\Source\User\SimSettlementsV2\ObjectReferences\SimPlot.psc" Line 2467
[ (FF0034FD)].simsettlementsv2:objectreferences:simplot.IsEligibleForConstruction() - "C:\Program Files (x86)\Steam\steamapps\common\CC-F\Data\Scripts\Source\User\SimSettlementsV2\ObjectReferences\SimPlot.psc" Line 556
[ (FF0034FD)].simsettlementsv2:objectreferences:simplot.AdvanceStage() - "C:\Program Files (x86)\Steam\steamapps\common\CC-F\Data\Scripts\Source\User\SimSettlementsV2\ObjectReferences\SimPlot.psc" Line 4873
[ (FF0034FD)].simsettlementsv2:objectreferences:simplot.OnTimer() - "C:\Program Files (x86)\Steam\steamapps\common\CC-F\Data\Scripts\Source\User\SimSettlementsV2\ObjectReferences\SimPlot.psc" Line 618
290 from simplot.AdvanceStage(): 116
5800 came from hudmanager.OnTimer(): 290
58 from hudmanager.OnMenuOpenCloseEvent(): 58
3538 came from plotmanager.OnTimer() 58
174 from unlockmanager.OnStageSet(): 58
If you add them up the numbers of creations and destructions don't match because another 3596 were created during the save. And I might have mistyped something.
Now let's ignore the fact that the structures are being created. That's not my point and that was solved already. At this time, I'm just using them to debug function calls.
Remember how many plots I said I have? It was about 3 hours ago for me, so I had to check the start of the post xD I had 29 plots. Notice the numbers I placed next to the function calls? I Dunno what that ID identifies [SS2_UnlockManager (
0D00EAFA)] but it is very curious and it looks like an identifier of the script itself. If I count the number of identical traces in the log, I get the number at the end of the line:
174 from unlockmanager.OnStageSet(): 58. 2 times for each of my plots
3538 came from plotmanager.OnTimer() 58. 2 times for each of my plots
58 from hudmanager.OnMenuOpenCloseEvent(): 58. 2 times for each of my plots
5800 came from hudmanager.OnTimer(): 290. 10 times for each of my plots
290 from simplot.AdvanceStage(): 116. 4 times for each of my plots
290 came from simplot.OnTimer(): 290. 10 times for each of my plots
Considering that the whole log was in a timespan of 32 minutes and that around 30minutes was spent saving the game (which means the clock for the timers were paused), does that mean that the above 'table' is the number of function calls in little more than 2min of gameplay? Do these numbers seem right to you
@kinggath? To me it seems a little excessive, but I might be misinterpreting them.
Sorry for the long post, but I think this is valuable information
EDIT: Had to remove the trace quotes cause of the character limit. I'll leave the first one just to serve as an example.