Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 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 /
avatar image
1
Question by ileonidmas · Apr 02, 2015 at 06:34 PM · iosapplicationscreenshotmemory-leakcapture

Does Application.CaptureScreenshot leak memory? (iOS)

I have created a simple application for iphone with one button from UI that executes just one line of code when I click on it. This is the code:

 public void CaptureScreenShot()
     {
 
         Application.CaptureScreenshot ("Screenshot.png");
 
     }

After I capture one screenshot, the memory increases by about 10 MB then drops only 7 MB

http://postimg.org/image/6r5tiaqjv/

When I take second screenshot, it goes up 7 MB, but doesn't drop at all, until I flip the device, and only then it goes to the starting amout of memory + 3 MB

http://postimg.org/image/am4m74kbv/

And then, if I want to take 2 screenshots in the row, it goes up like +25 MB of starting memory and drops 2 MB after a little period of time

http://postimg.org/image/5yyk5cwyz/

And even if I flip the device, it goes like 2 MB lower, but it is like +20 MB of the memory I use when I start the device. The point is, after taking at least one screenshot, I will never get the memory back. (The memory I had in the start)

Then I decided to try capture a screenshot manually with this code:

 public void TakeScreen()
     {
          // Timestamp returns the date, so each screenshot name would be unique
         string pngFile = Application.persistentDataPath+"/+Timestamp+".png";
         Texture2D texture = new Texture2D(Screen.width, Screen.height);
         texture.ReadPixels(new Rect(0, 0, Screen.width, Screen.height), 0, 0);
         texture.Apply();
         byte[] bytes = texture.EncodeToPNG();
         File.WriteAllBytes(pngFile,bytes);        
         DestroyObject( texture );
     }

Same thing happens with memory usage as with Application.CaptureScreenshot(); Could someone explain, what am I doing wrong, or is there a way to avoid this memory leak? I have the same problem when I try to save a picture from WebCamTexture():

 public void TakeSnap ()
     {
         // Timestamp returns the date, so each screenshot name would be unique
             string pngFile = Application.persistentDataPath+"/+Timestamp+".png";
         Texture2D texture = new Texture2D(wct.width, wct.height);
         texture.SetPixels32(wct.GetPixels32());
         texture.Apply ();
         var bytes = texture.EncodeToPNG();
         File.WriteAllBytes( pngFile,bytes);        
         DestroyObject( texture );
 
 }
Comment
Add comment · Show 3
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 ileonidmas · Apr 08, 2015 at 02:01 PM 0
Share

I tried, didn't work... Well, the application uses unnecessary memory. The app should take the screenshot and that is it. But it takes screenshot, and after saving it still uses a lot of CPU non-stop, and if I take one more, it uses even more

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

Did you ever resolve this issue?

avatar image ileonidmas · Sep 15, 2015 at 01:23 PM 0
Share

Nope, no response from anyone on other forums. And I wrote a report to unity developers, and I still didn't hear anything from them.

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

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

Does Application.CaptureScreenshot leak memory on IOS? 1 Answer

Specifying a camera using ScreenShotMovie and changing capture rate while not affecting playback rate 1 Answer

NotificationServices for remote notification is really working??? 0 Answers

Object references listed in profiler but not in hierarchy. 1 Answer

How to play sound during screenshot, even when device muted 1 Answer


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