Forum rules - please read before posting.

[Bug + Fix] Memory leak for animated cursor

edited June 2016 in Engine development
Hi :-h ,

I've been helping a friend of mine tracking down a memory leak that especially was a problem for the WebGL build and Firefox. It's always occuring while an animated cursor is shown. The memory usage in the Windows task manager increases and the Unity Profiler shows an increasing amount for "Total Object Count".

I think I've found the leak at PlayerCursor.cs:708 at PlayerCursor.RecordCursorTexture() and adding the following lines seems to fix it:

if (_currentCursorTexture != null)
{
   if (currentCursorTexture != null)
   {
       Destroy(currentCursorTexture);
   }
   currentCursorTexture = _currentCursorTexture;
}

It seems like the garbage collector isn't disposing of the old cursor texture here and you have to do it manually.

I hope that helps :)

Cheers,
Simon

EDIT: This issue appears in Version 1.51.

EDIT2: Sorry, the fix seems to produce some other problems (destroying main cursor too, DestroyImmediate(object, true) should be used, etc.). I will continue looking into this.

Comments

  • Hi again,

    First off, this only happens with software cursor.

    I've now tried introducing a variable that checks if the cursor texture was created dynamically with "new Texture" or rather if it's an animation. If that's the case and the currentCursorTexture is recorded again, it will use DestroyImmediate(currentCursorTexture, true);

    This seems to fix the problem for the "Total Object Count" in the Profiler, but the memory in the WebGL build is still increasing.

    I will look further into this tomorrow or maybe someone knows a fix for the problem until then :)

    Cheers,
    Simon
  • Thanks for the info, I'll investigate.
  • Update: I can confirm this issue will be fixed in the next AC release ;-)
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Welcome to the official forum for Adventure Creator.