- Korean, English OK!
- Indie game developer and C# programmer.
- Working on SunnySideUp and @stations.cretapark.me
* Repost, opinions do not represent the company.
In our case, some external asset make this trouble causes memory leak and it's hard to find root causes during profiling memory...
So make sure to free referencing instances on end of life-cycle!
🧵
#unitytips
In our case, some external asset make this trouble causes memory leak and it's hard to find root causes during profiling memory...
So make sure to free referencing instances on end of life-cycle!
🧵
#unitytips
class NI {
...
void OnDestroy() {
if (Child != null)
Child.Parent = null;
Child = null;
}
}
It'll break both of references so GC and asset system can free/unload these instances!
🧵
#unitytips
class NI {
...
void OnDestroy() {
if (Child != null)
Child.Parent = null;
Child = null;
}
}
It'll break both of references so GC and asset system can free/unload these instances!
🧵
#unitytips
- NI has reference count from it's Child member's instance member, _parent, this causes NI's managed wrapper instance still be alived on memory.
- MI has reference from native instance, NI's member, Child, causes GC cannot sure it's okay to free that instance.
🧵
#unitytips
- NI has reference count from it's Child member's instance member, _parent, this causes NI's managed wrapper instance still be alived on memory.
- MI has reference from native instance, NI's member, Child, causes GC cannot sure it's okay to free that instance.
🧵
#unitytips
class NI : ScriptableObject {
public MI Child;
}
class MI {
public NI Parent;
public MI(NI parent) {
Parent = parent;
}
}
NI asset = ...;
asset.Child = new MI(asset);
This causes cyclic reference so it cannot be freed completely even `Destroy(asset)`.
🧵
#unitytips
class NI : ScriptableObject {
public MI Child;
}
class MI {
public NI Parent;
public MI(NI parent) {
Parent = parent;
}
}
NI asset = ...;
asset.Child = new MI(asset);
This causes cyclic reference so it cannot be freed completely even `Destroy(asset)`.
🧵
#unitytips