Unity-Technologies / BoatAttack

Demo Project using the Universal RP from Unity3D
Other
2.53k stars 949 forks source link

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

Open DavidT76 opened 4 years ago

DavidT76 commented 4 years ago

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.

oahc09 commented 4 years ago

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.

ahmedaniss25 commented 3 years ago

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

Aqueuse commented 3 months ago

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

video has been removed :-/