yasirkula / UnitySimpleFileBrowser

A uGUI based runtime file browser for Unity 3D (draggable and resizable)
MIT License
851 stars 111 forks source link

Out of memory error when getting audio file result #23

Closed mdotstrange closed 4 years ago

mdotstrange commented 4 years ago

Hello and thank you for the great tools!

I'm getting a random out of memory error from line 341 of FileBrowserHelpers.cs return File.ReadAllBytes(sourcePath);

It appears it is called through me using if (FileBrowser.Success)

It happens randomly when loading audio files- file sizes from 1 megabyte to 50 megabytes will randomly get this error. The same audio file will randomly get the error if loaded in multiple times. Any idea on a direction for me to go to resolve this? Thank you for your time.

yasirkula commented 4 years ago

I'm guessing that the previously loaded audio clips stay in memory and at some point, device runs out of available RAM. If you are creating AudioClips using File.ReadAllBytes, try calling Destroy(previousAudioClip) for previously loaded audio clips so that they can be garbage collected.

mdotstrange commented 4 years ago

Thank you for the reply- I will give this a try- thanks again for all the great tools.