Skip to content

[GEN][ZH] Fix memory leaks within various AIAttackStateMachines #1351

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

Closed

Conversation

Mauller
Copy link

@Mauller Mauller commented Jul 23, 2025

This PR cleans up memory leaks within a few different AI state machines.

@Mauller Mauller self-assigned this Jul 23, 2025
@Mauller Mauller added Minor Severity: Minor < Major < Critical < Blocker Gen Relates to Generals ZH Relates to Zero Hour Memory Is memory related Fix Is fixing something, but is not user facing labels Jul 23, 2025
@@ -735,6 +736,8 @@ AIStateMachine::~AIStateMachine()
{
deleteInstance(m_goalSquad);
}

clear();
Copy link

Choose a reason for hiding this comment

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

This looks like it could change behaviour with what AIStateMachine does on clear?

Copy link
Author

Choose a reason for hiding this comment

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

Yeah i just noticed that there is also the signal to the ai.
it could be that the changes here can disappear if the problem is just cleanup within the states themselves.

@@ -1998,6 +2001,7 @@ AIAttackMoveStateMachine::AIAttackMoveStateMachine(Object *owner, AsciiString na
//----------------------------------------------------------------------------------------------------------
AIAttackMoveStateMachine::~AIAttackMoveStateMachine()
{
clear();
Copy link

Choose a reason for hiding this comment

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

Can you show what was leaking here?

Copy link
Author

@Mauller Mauller Jul 24, 2025

Choose a reason for hiding this comment

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

Various AIAttackstates that were appearing in the Generals shell map as being leaked after close.
I need to check back over it again later the same with the AIGuard state stuff.

Copy link
Author

@Mauller Mauller Jul 24, 2025

Choose a reason for hiding this comment

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

Checking it again, i think the issue is that the AIAttack states are leaking in a similar fashion to the guard states, i am going to repurpose this PR to implement their destructors and so that the other PR does not get too long.

Copy link
Author

Choose a reason for hiding this comment

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

So the leaking AI Attack states were just ones leaking due to the issue with the AI Guard states, this PR does not actually do anything helpful in the end.

Copy link

Choose a reason for hiding this comment

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

So it can be closed?

Copy link
Author

Choose a reason for hiding this comment

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

It was generals that i was seeing the leaked states within still, but i might not have had the AIGuard leak fix in place then, i will double check if there are leaking AI states there still and close this later if it's not going to be useful.

@Mauller
Copy link
Author

Mauller commented Jul 30, 2025

Yeah this is not needed in the end so going to close it, i think i was seeing things which the AI Guard state PR resolved.

@Mauller Mauller closed this Jul 30, 2025
@Mauller Mauller deleted the fix-ai-statemachine-memleaks branch July 30, 2025 19:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Fix Is fixing something, but is not user facing Gen Relates to Generals Memory Is memory related Minor Severity: Minor < Major < Critical < Blocker ZH Relates to Zero Hour
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants