Search Unity

memory always goes up on loading tuxture

Discussion in 'Flash' started by ranye, Sep 10, 2013.

  1. ranye

    ranye

    Joined:
    Sep 10, 2012
    Posts:
    18
    i use www to dynamiclly load texture in unity flash,
    host swf will sendMessage to unity swf to load texture.
    i try to release memory by destroying the asset,
    but memory always go up after several load calls.
    if switch to an empty scene memory doesn't change
    if switch back to main scene memory doesn't change.
    Resources.UnloadUnusedAssets(); and System.GC.Collect(); don't help.
    who to manage memory?
    Code (csharp):
    1.  
    2.     IEnumerator LoadUniformPNG(string name)
    3.     {
    4.         string path;
    5.         if (Application.platform == RuntimePlatform.FlashPlayer)
    6.             path = "StreamingAssets/" + name + ".png";
    7.         else
    8.             path = "file:///" + Application.streamingAssetsPath + "/" + name + ".png";
    9.         Debug.Log(path);
    10.         WWW www = new WWW(path);
    11.         yield return www;
    12.         Debug.Log("www png finish");
    13.         DestroyImmediate(player.renderer.material.mainTexture, true);
    14.         player.renderer.material.mainTexture = www.texture;
    15.         www = null;
    16.     }
    17.  
    btw, memory is ok in editor
     
    Last edited: Sep 10, 2013