0

In our iPad app we need to load fbx files(of size 1MB - 100MB) as asset bundles. I started testing with a fbx file of size 26MB and it creates an asset bundle of size 17MB. When I run the test scene to load this asset bundle in the iPad it load after around 1 minute. And then I get a memory warning. I monitored the memory using Xcode and it seems that memory usage increase from around 1MB to 65Mb and then just before the model show up memory increase to around 175MB at once. Below is my code.

I have seen similar issues posted by other users. But I didn't see a proper solution to it in any of these threads. As I read in these threads, I think the memory increases when uncompressing the asset bundle .But I don't understand why it goes unto around 170MB.

What can we do to reduce the memory usage?
Thanks

    public class CachingLoad : MonoBehaviour {
    public string BundleURL;
    public string AssetName;
    public int version;

    void Start() {
        StartCoroutine (DownloadAndCache());
    }

    IEnumerator DownloadAndCache (){
        // Wait for the Caching system to be ready
        while (!Caching.ready)
            yield return null;

        BundleURL = "http://10.30.3.228:8080/TestDownload/assetBundle1.unity3d";
        // Load the AssetBundle file from Cache if it exists with the same version or download and store it in the cache
        using(WWW www = WWW.LoadFromCacheOrDownload (BundleURL, version)){
            yield return www;
            if (www.error != null)
                throw new Exception("WWW download had an error:" + www.error);
            AssetBundle bundle = www.assetBundle;
            if (AssetName == "")
                Instantiate(bundle.mainAsset);
            else
                Instantiate(bundle.Load(AssetName));
                    // Unload the AssetBundles compressed contents to conserve memory
                    bundle.Unload(false);

        } // memory is freed from the web stream (www.Dispose() gets called implicitly)
    }
}
Madhu
  • 1,209
  • 2
  • 22
  • 28
  • a stored file size is usually much smaller than in memory size. For instance any PNG file still takes up the space it would take as if it were saved as BMP, once in memory. - Similarly, a model will take less memory, but once loaded, all of the textures and other characteristics get processed into memory. Try running it in the ide and check the memory size of the game, instead of the files. –  Jan 14 '14 at 18:03
  • Thanks. This is not really a game app. It's just one fbx file(25MB) added to a empty scene. There isn't anything else. When I load the model in the unity editor, under stats I see VRAM usage shows 2.9MB to 50.8MB. In iPad when it runs it increase to around 70MB and then suddenly it increase to around 170MB just before the model show up and then goes back to 117MB and stays there after its loaded. – Madhu Jan 14 '14 at 21:19

0 Answers0