I am having memory leaks and have appeared to have isolated the area causing it.
It seems I am memory leaking with setting checkbox values.
This was working fine in the beginning and then started memory leaking later on.
I got the memory leaking right before I got screwed over and was not able to work on the project for five months. It used to work without problems and then all of a sudden it started having problems.
I’m not sure what you are trying to say by doing it once only?
I have isolated the memory leak to this exact block of code, and its not making much sense to me where the memory leak is being caused – all it is doing is setting values of a slider and material.
It is instancing the material, it should be doing this and creating the instance even when I just alter the slider values and it is setting it. It was working at first so I dont think it is creating multiple instances each time the material is edited by slider values. This exact block of code used to be fine and work, now its causing issues.
Also, if I comment the posted block of code, I can still edit the sliders and its fine with no leaks only setting the values in that code block are leaking it.
I added to that last post that I can comment out that block of code specifically (posted code), and I can go in game and set the slider values like I show in the video and it works fine updating the materials, however only setting them in that code block is causing the problem.
I have isolated the problem further it is in this code specifically, and if I were to comment it out (so that its not executing changes without me editing it first in game) and set them myself in game it will memory leak from the checkboxes being checked in game, the sliders were fine and did not memory leak upon being changed in game.
This is hitting checkboxes on a material. A matcap type of material.
For anyone dealing with toggles / checkboxes that hits this on search I updated from unity 2019 and the error went away, and one of two checkboxes was left with a stack overflow error. This is the solution to it.
Thanks for the followup! So the version of Unity you had did have a memory leak, and when you upgraded you discovered you fixed the leak, but then discovered that you now had a runaway event that triggered a stack overflow?
Or was it always a stack overflow from day one and not a memory leak??
Upon going to get this screenshot I found out if I started the checkboxes turned off instead of turned on the memory leaking went away, so I might stay in the older version with that happening. It did also throw a stack error this time for the first time.
Unity 2021.1.16f1 no longer memory leaked on either toggle, however, one of the two checkboxes was now giving the stack overflow.
What’s weird is that you suddenly started getting StackOverflow. The logic loop had to be in there before!
I wonder if perhaps an older version of the Unity event handler actually had stateful counting of how many times it went through (like an event depth limit) and then would abandon the call to keep it from going infinitely recursive, and yet when it abandoned it actually leaked something by the abnormal termination.