Search Unity

Why `AssetBundle.LoadFromFile` and `AssetBundle.LoadFromStream` have a different memory cost?

Discussion in 'Asset Bundles' started by shelllee, Dec 7, 2021.

  1. shelllee

    shelllee

    Joined:
    Apr 12, 2018
    Posts:
    18
    1. What happened

    I found `AssetBundle.LoadFromFile` and `AssetBundle.LoadFromStream` have a different memory cost on `SerializedFile` metrics when load bundle which contains texture asset and compressed with LZ4.​

    2. How to reproduce it

    1. Download the attachment unity project `AssetBundle.zip`
    2. Select `AssetBundle` command in main menu, and then click `Build` sub-command. It will build a texture asset(`Assets/Arts/icon`) to bundle(`AssetBundles/asset_bundle.bundle`) with `ChunkBasedCompression.BuildAssetBundleOptions` (LZ4) option
    3. Open and play `Scenes/SampleScene` scene, there would be some commands in game view
    4. Try these commands, and compare `SerializedFile` metrics in `Profiler/Memory/Detail` panel


    load from file cost 5.3k:

    upload_2021-12-7_22-6-36.png

    load from stream cost 125.3k:

    upload_2021-12-7_22-7-10.png
     

    Attached Files: