Search Unity

Memory Leak in GetPixels and GetPixels32

Discussion in 'Windows' started by Jonny-Roy, Oct 2, 2013.

  1. Jonny-Roy

    Jonny-Roy

    Joined:
    May 29, 2013
    Posts:
    666
    There is a memory leak using either GetPixels method with any texture, using this simple script:

    using UnityEngine;
    public class TextureTest : MonoBehaviour
    {
    public Texture2D encoded;
    void Start()
    {
    this.encoded = new Texture2D(256,256);
    }
    void Update()
    {
    this.encoded.GetPixels32();
    }
    }

    If you leave this running for a while the memory will eventually (after about 1 minute) run out of memory and crash, using a larger texture will cause a much quicker crash and the memory increase is clearly visible in the profiler.

    Any suggestions on a work around?

    Thanks,

    Jon
     
  2. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,674
    That sounds like a bug. Is it happening only on Windows Phone? What about other platforms (editor, windows store apps, anything else)?
     
  3. Jonny-Roy

    Jonny-Roy

    Joined:
    May 29, 2013
    Posts:
    666
    I'll do a quick test on Windows Store in a moment, but no the editor does not have the same issue, I'm fairly sure it's windows phone only.
     
  4. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,674
    I'll be waiting for your answer.
     
  5. Jonny-Roy

    Jonny-Roy

    Joined:
    May 29, 2013
    Posts:
    666
    No leak on Windows Store, tested on Windows RT tablet, and I tested both methods, although they are a little slow at 66ms.

    I've submitted a bug report as number 567103, with a simple repro project! Hope that helps.
     
  6. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,674
    Thanks! A bug reports helps a lot, especially with a bug report we won't forget to fix it for sure :).