Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Interaction Menu - fix a crash when loading savegames #7115

Merged
merged 8 commits into from
Aug 2, 2019
Merged

Conversation

commy2
Copy link
Contributor

@commy2 commy2 commented Jul 28, 2019

When merged this pull request will:

  • Currently any mission with sufficiently enough soldiers placed crashes when loading a savegame, because the game runs out of memory when deserializing arrays.

  • The addInteractionToClass function from interact_menu with allowInheritance flag set adds an (retroactively applied) Init event handler to the object class for every added action, so the actions can be added to descendant classes of the base class the action was added to.

  • ACE Medical adds a lot of actions to the CAManBase base class.

  • This means ~250 more Init events on CAManBase when Medical is loaded.

  • The array is referenced on every CAManBase object and thus creates a big save file, which cannot be loaded without running out of memory.

  • This PR rewrites the allowInheritance part of the addInteractionToClass function to drastically reduce the memory usage.

  • Realistically this is just a BI bug we will keep running into, but we can avoid it with this memory optimization.

@commy2 commy2 added kind/bug-fix Release Notes: **FIXED:** kind/optimization Release Notes: **IMPROVED:** MedicalRewrite-Rectified labels Jul 28, 2019
@commy2 commy2 added this to the 3.13.0 milestone Jul 28, 2019
@commy2
Copy link
Contributor Author

commy2 commented Jul 28, 2019

Thanks @Dystopian :)

@PabstMirror
Copy link
Contributor

Most inherited actions were for CAManBase (from medical)
So I added special handling for just that class,
it lets us do one check of isKindOf && pushBackUnique per unit init instead of once for each action

117 Units
Before
Init: 0.871338s
Place 8 Units: 0.0100098s / 8 = 1.25122ms

After
Init: 0.585205s
Place 8 Units: 0.000976563s / 8 = 0.12207ms

@PabstMirror
Copy link
Contributor

This will break WIP #6295
But I think it will actually be much easier to implement

Copy link
Contributor Author

@commy2 commy2 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Capitalization

addons/interact_menu/XEH_preInit.sqf Outdated Show resolved Hide resolved
addons/interact_menu/functions/fnc_addActionToClass.sqf Outdated Show resolved Hide resolved
@PabstMirror PabstMirror changed the title fix a crash when loading savegames Interaction Menu - fix a crash when loading savegames Jul 31, 2019
@PabstMirror PabstMirror merged commit 0fd4424 into master Aug 2, 2019
@PabstMirror PabstMirror deleted the fixSPCrash branch August 2, 2019 01:52
@PabstMirror PabstMirror modified the milestones: 3.13.0, 3.13.0-temp2 Dec 30, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug-fix Release Notes: **FIXED:** kind/optimization Release Notes: **IMPROVED:**
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants