Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
  • Help Room /
avatar image
1
Question by oliver-jones · Sep 14, 2015 at 09:03 PM · iostexture2dmemorymemory-leak

iOS - Memory Issue with Dynamic Texture2D [Paid]

Hello,

I'm having an issue with managing my memory when messing around with dynamic texture2Ds. I'm building a mobile app that has an image editor in it.

The user basically takes a photo using the device camera. This image is then cropped and resized to 512 x 512.

The image then goes through a simple pixel adjustment modifier - which basically duplicates the image 15 times, each with a different colour scheme. The user then selects 1 of the 15 images to keep.

Once this process is done, I destroy all images but the one selected, but my memory isn't cleared up that much.

I've had a look around the internet, and it seems iOS is pretty hard to memory manage with dynamic assets.

So what I've done to remove the textures is this:

 var ob = FindObjectsOfType (Texture2D);
 for (var t : Texture2D in ob){
      if(NeedToKeep(t) == false)
           DestroyImmediate(t, true);
 }

So this searches the entire project for active loaded Texture2Ds, and destroys them if not needed (destroys all textures but the one the user selected).

I then do this:

 System.GC.Collect();
 Resources.UnloadUnusedAssets();

So initially, the app uses 30Mb of Memory, which is normal at this point.

With the image taken, the memory jumps to 95Mb of Memory.

The image adjustment (duplication of 15) takes place with the memory jumping to 175Mb of Memory, bearing in mind that the images are only (512x512) x 15 duplications.

Once the image is selected, it does my memory clean - memory goes back down to 140Mbs, which is lower ... but nothing compared to the start. I should only have ONE image loaded in memory which is 512x512. It can't be taking up 110Mbs of Memory? Surely?

Please advise, thanks.

---- Additional ----

When I do a complete memory clean - removal ALL images in memory, the memory goes down to 95Mbs. So now there should be no images in memory, just like it started. Yet it's still no where near the 30Mbs from start.

Why is this? This is becoming a serious issue as it causes my App to crash after a couple of uses.

Comment
Add comment · Show 2
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image steakpinball · Sep 21, 2015 at 08:21 PM 0
Share

Have you verified FindObjectsOfType (Texture2D) is giving you the textures? The docs suggest it doesn't return textures.

avatar image oliver-jones · Sep 22, 2015 at 10:00 AM 0
Share

@ brianturner : It's defiantly giving me something, it's printing the names of each texture, and then I destroy them. If I do the search again, they do not show on the console, so they're defiantly being removed, just not from the iOS memory.

0 Replies

· Add your reply
  • Sort: 

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

28 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

iOS - Placing Texture2Ds in Array cause Memory Leak? 0 Answers

Memory Profiler shows assets are loaded that are not referenced anywhere in scene 0 Answers

Memory error pls help 0 Answers

Memory leak with creating a new Texture2D 0 Answers

assetBundle memory can not be free 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges