Quantcast
Channel: Questions in topic: "ios"
Viewing all articles
Browse latest Browse all 4709

iOS Possible memory leak when large TextAsset is loaded

$
0
0
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. My problem here is that on iOS 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 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 parser.Xml = xmlFile.text; This is more or less everything I could think of to release the memory parser.Xml = null; DestroyImmediate(xmlFile,true); System.GC.Collect(); request = null; bundle.Unload(true); Resources.UnloadUnusedAssets(); } I've tried everything I could think of to get it to release the memory, not sure if its a memory leak or if I'm missing something here, I only have this issue on iOS device (profiled using instruments). Don't see any evidence of it when I profile memory in editor

Viewing all articles
Browse latest Browse all 4709

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>