Spout4Unity icon indicating copy to clipboard operation
Spout4Unity copied to clipboard

Memory leak in CPU and GPU

Open ijreil opened this issue 9 years ago • 3 comments

I’m building an application where Unity would send one texture to VVVV via Spout. Working on it, I’ve noticed that every time I kill Unity player, and reopen it again (no matter how much time passed) while leaving VVVV running, there are 15 Mb more or less that always sum up to the memory.

I first thought it could be VVVV related, so been playing with fromsharedtexture node to see if I could find out anything, but I haven’t. So I’ve made some tests in a PC with AMD Radeon E8860 dedicated Graphics and Unity 5.3.4f1 version:

  • SENDER IN UNITY EDITOR: I’ve tried the Unity Spout Demo alone, in Editor, just playing and stoping and the memory leak is present. Also, not only memory is added to the Ram, but also to the GPU. I’ve tried with simpleSender scene and with Spout2 Sender scene, both add 15 MB to CPU and GPU each time I hit play after previous stop.
  • SENDER COMPILED, NO UNITY EDITOR: Next, what I have done is compile those scenes to try them without Editor. This time, executing the compiled scenes there has been no leak, tried executing and killing them several times but no memory has been added to Ram nor GPU.
  • SENDER COMPILED , NO UNITY EDITOR + VVVV RECEIVER: Next, I have opened VVVV receiver to test the compiled scenes from the previous test with a receiver opened. This time there has been leak, same as before, 10-15 MB are added to both, CPU and GPU, each time I execute and stop the compiled scene, with receiver remaining opened and rendering.

Looking at logs, I've seen that Awake from Spout scripts executes again after onDisable, so maybe here is the problem? A bunch of new objects is created and not liberated anymore?

What I can't understand is why, when Script is compiled there is no leak when VVVV receiver is not present and rendering.

ijreil avatar May 05 '16 07:05 ijreil

I've tried removing [ExecuteInEditMode] so Awake() doesn't execute again on close but the leak is still there. Also, I've tried to deactivate Spout script to see if SpoutSender could be the problem, but there isn't. So it may be the something with the Spout script.

ijreil avatar May 05 '16 10:05 ijreil

I have to look at this but at the moment i have no time. But thanks for your testing. This alll sounds strange. Did you tested it with an older Unity Version? Perhaps Unity change the way the underlying native textures are handled.

sloopidoopi avatar May 05 '16 15:05 sloopidoopi

Sorry for the late reply, been working in another project I haven't had time to test this. Do you recommend me to downgrade to any specific version?

ijreil avatar May 19 '16 07:05 ijreil