BoatAttack icon indicating copy to clipboard operation
BoatAttack copied to clipboard

A Native Collection has not been disposed, resulting in a memory leak error

Open DavidT76 opened this issue 4 years ago • 3 comments

2020-03-09 After I finished a race and was brought back to the main menu screen. I noticed this error message as you can also see in the screenshot:

A Native Collection has not been disposed, resulting in a memory leak. Allocated from: Unity.Collections.NativeArray`1:.ctor(Int32, Allocator, NativeArrayOptions) WaterSystem.BuoyantObject:SetupData() (at Packages\com.verasl.water-system\Scripts\BuoyantObject.cs:99) WaterSystem.BuoyantObject:Init() (at Packages\com.verasl.water-system\Scripts\BuoyantObject.cs:58) WaterSystem.BuoyantObject:OnEnable() (at Packages\com.verasl.water-system\Scripts\BuoyantObject.cs:105)

I was using the latest version of the Git clone of this project with Unity version 2019.3.4f1 when this error occurred.

DavidT76 avatar Mar 09 '20 20:03 DavidT76

2020-03-09 After I finished a race and was brought back to the main menu screen. I noticed this error message as you can also see in the screenshot:

A Native Collection has not been disposed, resulting in a memory leak. Allocated from: Unity.Collections.NativeArray`1:.ctor(Int32, Allocator, NativeArrayOptions) WaterSystem.BuoyantObject:SetupData() (at Packages\com.verasl.water-system\Scripts\BuoyantObject.cs:99) WaterSystem.BuoyantObject:Init() (at Packages\com.verasl.water-system\Scripts\BuoyantObject.cs:58) WaterSystem.BuoyantObject:OnEnable() (at Packages\com.verasl.water-system\Scripts\BuoyantObject.cs:105)

I was using the latest version of the Git clone of this project with Unity version 2019.3.4f1 when this error occurred.

In BuoyantObject.cs change the code can fix it: private void OnDisable() { LocalToWorldJob.Cleanup(_guid); // bool isNonPhysicalType = _buoyancyType == BuoyancyType.NonPhysical || _buoyancyType == BuoyancyType.NonPhysicalVoxel; if (isNonPhysicalType && _samplePoints != null && _samplePoints.IsCreated) { _samplePoints.Dispose(); } // } if _buoyancyType is physical type, in LocalToWorldJob.cs it will dispose the nativearray, but non physical type not disposed.

oahc09 avatar Apr 06 '20 03:04 oahc09

Problem fixed here : https://youtu.be/w6cRuLJQ7E0

ahmedaniss25 avatar May 21 '21 02:05 ahmedaniss25

Problem fixed here : https://youtu.be/w6cRuLJQ7E0

video has been removed :-/

Aqueuse avatar Jun 03 '24 18:06 Aqueuse