-
Notifications
You must be signed in to change notification settings - Fork 4.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[MLA-1909] Match3 and Camera/RenderTexture sensor GC improvements #5233
Conversation
for (var i = 0; i < sensors.Count; i++) | ||
{ | ||
var sensor = sensors[i]; | ||
if (sensor is IDisposable disposableSensor) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fannnncy
{ | ||
if (!ReferenceEquals(null, m_Sensor)) | ||
{ | ||
m_Sensor.Dispose(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could this be a double dispose? looks safe since the sensor checks for null. Just curious if it's actually needed or not.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I made sure all the sensor.Dispose's are idempotent - they check for null textures first, then set the texture to null.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks good, just not sure if the extra dispose in the components are needed anymore since the sensor disposal happens in Agent.
Proposed change(s)
Texture2D
s to avoid allocationsDispose()
on anyISensor
s that implementIDisposable
.Match3Sensor
Before


After
GridWorld (Camera + RenderTexture Sensors)
Before


After
Useful links (Github issues, JIRA tickets, ML-Agents forum threads etc.)
https://jira.unity3d.com/browse/MLA-1909
https://jira.unity3d.com/browse/MLA-1910
https://jira.unity3d.com/browse/MLA-208
Types of change(s)
Checklist
Other comments