- Home /
(Remote Config) Calling ConfigManager.FetchConfigs from FixedUpdate throws "A Native Collection has not been disposed, resulting in a memory leak."
I've got this Error In unity 3D after I started using Remote Config:
A Native Collection has not been disposed, resulting in a memory leak. Allocated from:
Unity.Collections.NativeArray`1:.ctor(Byte[], Allocator)
UnityEngine.Networking.UploadHandlerRaw:.ctor(Byte[])
Unity.RemoteConfig.ConfigManagerImpl:DoRequest(String) (at Library\PackageCache\com.unity.remote-config-runtime@1.0.1\Runtime\ConfigManagerImpl.cs:267)
Unity.RemoteConfig.ConfigManagerImpl:PostConfig(Object, Object) (at Library\PackageCache\com.unity.remote-config-runtime@1.0.1\Runtime\ConfigManagerImpl.cs:204)
Unity.RemoteConfig.ConfigManagerImpl:FetchConfigs(appAttributes, userAttributes) (at Library\PackageCache\com.unity.remote-config-runtime@1.0.1\Runtime\ConfigManagerImpl.cs:188)
Unity.RemoteConfig.ConfigManager:FetchConfigs(appAttributes, userAttributes) (at Library\PackageCache\com.unity.remote-config-runtime@1.0.1\Runtime\ConfigManager.cs:96)
Movement:FixedUpdate() (at Assets\scripts\Movement.cs:27)
if you look at the last line It's pointing you to a line of your own code, so maybe read that instead of giving us an unsolvable error with zero context.
Answer by andrew-lukasik · Jun 29, 2021 at 06:51 AM
This error says that your script Assets\scripts\Movement.cs
( at FixedUpdate
) calls ConfigManager
which allocates memory for networking communication and that memory wasn't deallocated.
If you see this warning only once when play mode ends I would ignore it for now. It might be temporary and minor package issue.
But if you're getting spammed with this message A LOT then to fix this you must help this ConfigManager
deallocate it's memory somehow or stop calling it.
And how I suppose to know what in your script at line 27, while you shared none of it's content, exactly? :T
Sorry... I thought its more like a principle... here is the code:
private void Awake()
{
ConfigManager.FetchCompleted += UpdateData;
ConfigManager.FetchConfigs<appAttributes, userAttributes>(new appAttributes(),new userAttributes());
}
void FixedUpdate()
{
if(Input.GetKeyDown(KeyCode.Space))
ConfigManager.FetchConfigs<appAttributes, userAttributes>(new appAttributes(), new userAttributes());...
}
void UpdateData(ConfigResponse response)
{
ConfigManager.appConfig.GetInt("jump power");
}
Line 27 is the content of the if statment
According to Remote Config's documentation page and implementation examples provided on the forum, ConfigManager.FetchConfigs
is meant to be called once, for example, on Awake
and definitely not on FixedUpdate
. So remove it from there and you're good.
Answer by ravenclarico · Jun 29, 2021 at 03:57 AM
you can double click the last line of the error to jump to the point in your script that caused the problem. (if you use visual studio, which i highly recommend)
This is helpful only when working with a stack trace that points to your code. In this specific case will it would open ConfigManagerImpl.cs:267
file which is both foreign and won't be of much help. It's better to just understand what stacktrace says.
Your answer
Follow this Question
Related Questions
Can iPhone remote be used from standard Unity? 2 Answers
Unity Remote 3 Problem 1 Answer
Remote Unity build? 2 Answers
Can't find unity-remote-4 in AppStore 3 Answers
How to enable head tracking in Google Cardboard via Unity Remote on OSX? 1 Answer