Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

memory leak when using assetbundles on iOS?

Discussion in 'iOS and tvOS' started by cloud_zere, Dec 21, 2011.

  1. cloud_zere

    cloud_zere

    Joined:
    Nov 8, 2010
    Posts:
    8
    We use a lot of assertbundles in our game.
    the step I do to create an object from an assetbundle is:
    (1) create an www instance and wait until it's done.
    (2) get the mainasset of the assetbundle
    (3) Instantiate the mainasset
    ------------------------------------------------------
    then when I unload the assetbundle.
    I followed these steps:
    (4) call GameObject.Destory on the instantiated object.
    (5) call assetbundle.unload(true)
    (6) call www. disposed method
    (7) call resources.unloadunusedassets()

    done! but the memory used now is 0.5MB larger than the beginning.(viewed in instruments/Activity monitor)
    for some large assetbundles,it increased more....
    for any single assetbundle,create -> destory->create -> destory will not increase the total memory.
    but in our game we will load and destory many assetbundles.and according to the test.the memory will increase more and more after we load diffrent assetbundle...

    in my opnion:
    the assetbundle is an zip bundle with all assets in it.
    when we load the assetbundle by www class.it will read the whole assetbundle in the memory and decompresse it,(the momory now should be sum of raw assetbundle size and decompressed size)
    when we load the asset from the assetbundle(the memory also increaed but I don't known what it does)
    instantiate also increased the memory(commit data to gpu ?)
    unload steps do the opposite things
    www.disposed will unload the raw assetbundle(compressed data)
    assertbundle.unload will unload the assets in the assetbundle(raw decompressed data)
    gameobject.destory release the instance to assets and objects on the mono heap
    resources.unloadunusedassets will unload assets data(including data on vram like texture,vbo)
    Am I right?:)

    So my questions is: why the memory increased after I released the www,assetbundle,gameobject?Do I miss something?
     
  2. techmage

    techmage

    Joined:
    Oct 31, 2009
    Posts:
    2,133
  3. slight

    slight

    Joined:
    May 11, 2009
    Posts:
    1
    I got the same problem in PC Standalone, any farther news about this?