Skip to content

Memory leaks due to incorrect OnDestroy method #54

@JonnyOThan

Description

@JonnyOThan

public void Destroy()

I noticed this in someone's logs:

[LOG 07:36:19.411] [KSPCF:MemoryLeaks] A destroyed WildBlueTools:WBIPartDeprecator instance is owning a onLevelWasLoadedGUIReady callback. No action has been taken, but unless this mod is relying on this pattern, this is likely a memory leak.
[LOG 07:36:19.411] [KSPCF:MemoryLeaks] A destroyed WildBlueTools:WBIRefineryAppButton instance is owning a onGUIApplicationLauncherReady callback. No action has been taken, but unless this mod is relying on this pattern, this is likely a memory leak.
[LOG 07:36:19.411] [KSPCF:MemoryLeaks] A destroyed WildBlueTools:WBTAppButton instance is owning a onGUIApplicationLauncherReady callback. No action has been taken, but unless this mod is relying on this pattern, this is likely a memory leak.
[LOG 07:36:19.412] [KSPCF:MemoryLeaks] A destroyed WildBlueTools:ModCategorizer instance is owning a onGUIEditorToolbarReady callback. No action has been taken, but unless this mod is relying on this pattern, this is likely a memory leak.
[LOG 07:36:19.412] [KSPCF:MemoryLeaks] A destroyed WildBlueTools:WBIToolTipManager instance is owning a onEditorPartEvent callback. No action has been taken, but unless this mod is relying on this pattern, this is likely a memory leak.

I was surprised to notice that this class does try to clean up its event handlers - but the method is named wrong so Unity isn't going to call this! It should be OnDestroy not Destroy.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions