# iOS Bundle-loading memory, on loading text-asset

**URL:** https://discussions.unity.com/t/ios-bundle-loading-memory-on-loading-text-asset/597132
**Category:** Mobile
**Tags:** iOS
**Created:** [September 11, 2015, 8:16am UTC](https://discussions.unity.com/t/ios-bundle-loading-memory-on-loading-text-asset/597132 "2015-09-11T08:16:39Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![Dessouky](https://avatars.discourse-cdn.com/v4/letter/d/ebca7d/32.png) [@Dessouky](https://discussions.unity.com/u/Dessouky)
#### Post date: [September 11, 2015, 8:16am UTC](https://discussions.unity.com/t/ios-bundle-loading-memory-on-loading-text-asset/597132/1 "2015-09-11T08:16:39Z")

</div>

I have a large xml file which is loaded from a TextAsset in an asset bundle, once loaded I parse the elements and use the data contained to create a database of objects with various features and parameters.

There is a surprisingly large memory spike when I assign the TextAsset.text to a string, or read it using a string reader. I can manage all memory increases due to the bundle itself, by unloading the bundle, unloading unused assets and destroying the text asset. but nothing I do seems to get rid of the increase created by assigning the TextAsset.Text to a string. I’ve added the code snippet I’m testing below.

This part works just fine, the memory used by loading the bundle request and the Text asset is released when I destroy the textasset and unload unused assets

```csharp
if (bundle.mainAsset != null)
                {
                    AssetBundleRequest request = bundle.LoadAssetAsync("data", typeof(TextAsset));

                    yield return request;
 
                    TextAsset xmlFile = request.asset as TextAsset;

```

The Parser.Xml is a string, I’ve also tried directly loading it to an XMLDoc, and using a stringReader, once it loads the text into the string, the memory goes up and will not go down no matter what I do after

```csharp
parser.Xml = xmlFile.text;

```

This is more or less everything I could think of to release the memory

```csharp
                    parser.Xml = null;
                    DestroyImmediate(xmlFile,true);
                    System.GC.Collect();
                    request = null;
                    bundle.Unload(true);
                    Resources.UnloadUnusedAssets();

       }

```

I’m not really sure if its a memory leak or if I’m missing something here, this issue seems to only happen on iOS device (profiled using instruments). Don’t see any evidence of it when I profile memory in editor

---

<div class="post-metadata">

### Author: ![perlohmann](https://dub1.discourse-cdn.com/unity/user_avatar/discussions.unity.com/perlohmann/32/497335_2.png) [@perlohmann](https://discussions.unity.com/u/perlohmann)
#### Post date: [September 11, 2015, 1:11pm UTC](https://discussions.unity.com/t/ios-bundle-loading-memory-on-loading-text-asset/597132/2 "2015-09-11T13:11:42Z")

</div>

It is worth to note that the data xml file is 20+ mb.

---

<div class="post-metadata">

### Author: ![perlohmann](https://dub1.discourse-cdn.com/unity/user_avatar/discussions.unity.com/perlohmann/32/497335_2.png) [@perlohmann](https://discussions.unity.com/u/perlohmann)
#### Post date: [September 15, 2015, 8:12am UTC](https://discussions.unity.com/t/ios-bundle-loading-memory-on-loading-text-asset/597132/3 "2015-09-15T08:12:58Z")

</div>

bump =(
