Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Memory leaking problem with AssetBundle

Discussion in 'Flash' started by Cafe, Aug 5, 2013.

  1. Cafe

    Cafe

    Joined:
    Jan 21, 2013
    Posts:
    21
    Code (csharp):
    1. public static function AssetBundle_CreateFromMemory_ByteArray($binary: CLIByteArray): AssetBundleCreateRequest {
    2.             var $binary_lengthInBytes: int = $binary == null ? 0 : (($binary.Length * 1) + 4);
    3.             var dataPtr: int = UnityNative.GetStorageForDataBlock($binary_lengthInBytes);
    4.             var currentDataPtr: int = dataPtr;
    5.             var $binary_ptr: int = $binary == null ? 0 : currentDataPtr;
    6.             if ($binary != null) {
    7.                 var _0: int = $binary_ptr;
    8.                 var _1: int = $binary.Length;
    9.                 UPPReplace.writeInt(_1, _0);
    10.                 _0 += 4;
    11.                 {
    12.                     UnityNative.heap.position = _0;
    13.                     UnityNative.heap.writeBytes($binary.elements, 0, _1);
    14.                 }
    15.             }
    16.             var argsPtr: int = UnityNative.currentSP - 4;
    17.             UPPReplace.writeInt($binary_ptr, argsPtr);
    18.             UnityNative.AssetBundle_CUSTOM_CreateFromMemory(argsPtr);
    19.             return UnityNative.marshallmap.getObjectWithId(UnityNative.r_g0);
    20.             UnityNative.ReleaseStorageForDataBlock(dataPtr);
    21.         }
    22.  
    We can figure out that the ReleaseStorageForDataBlock is called after return. So the memory leaking exists ever since I load the AssetBundle.
     
  2. RalphH

    RalphH

    Unity Technologies

    Joined:
    Dec 22, 2011
    Posts:
    592
    Thanks for pointing this out. It's fixed and will be in a future build of Unity.

    In future, to keep things trackable for us and yourself, please file a bug.
     
  3. Cafe

    Cafe

    Joined:
    Jan 21, 2013
    Posts:
    21
    I've written a file that with the same code as above with return last. But the memory still isn't released. It seems that the UnityNative release doesn't work.
     
  4. RalphH

    RalphH

    Unity Technologies

    Joined:
    Dec 22, 2011
    Posts:
    592
    I can't speak to what you did, but I know tested that the changes I did to the code converter now mean memory is properly being released.
     
  5. Cafe

    Cafe

    Joined:
    Jan 21, 2013
    Posts:
    21
    Can I get the fixed version? Or do I need to wait for the official release?
    There's a premium support available in the store. Will it solve this bug for us?
     
  6. RalphH

    RalphH

    Unity Technologies

    Joined:
    Dec 22, 2011
    Posts:
    592
    You will have to wait for the official release, premium support does not offer custom builds.