- Home /
How to free memory of UnityWebRequest?
How can I free the data of UnityWebRequest at Unity WebGL? I am using it to load AssetBundle for most of the data but still unable to release the memory of UnityWebRequest.data because JavaScript.ArrayBuffer is increasing everytime i make a request.
using (UnityWebRequest webReq = UnityWebRequest.Get(_filePath));
.
.
webReq.Dispose()
Everytime I unload the scene, i will call the dispose function
AssetBundle.UnloadAllAssetBundles(true)
Nothing is happens. Is there something i did wrong? Do I have to do the loading at JavaScript followed by releasing the memory of that data? I was thinking of doing something like this for JavaScript side but it will always result in memory out of bound for obvious reasons.
function FreePointer(_arrayOfBytes, _byteLength)
{
console.log("free array of bytes: " + _arrayOfBytes);
gameInstance.Module._free(_arrayOfBytes);
console.log("Delete array");
delete _arrayOfBytes;
}
s
Answer by Roycemedia · May 29, 2020 at 11:06 AM
Nevermind. The memory leak comes from instantiation of GameObject from AssetBundle. Though I prevented memory leak by loading file from JavaScript, then explicitly release the memory at JavaScript Side.