question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Design Choice Discussion] Instancers and Garbage Collection

See original GitHub issue

https://discord.com/channels/640589221136171020/643165315546742785/1000332183057203210

Scriptable Objects (even the in-scene in-memory runtime copies) are not free’d if there is no reference pointing to it like normal objects (no garbage collection).

Freeing them requires to call Resources.UnloadUnusedAssets which is a kinda performance heavy call.

Also it is not really possible to Destroy the atom-instances in the instancers OnDisable since there could be remaining references (if destroy works at all for them).

When fiddling around with my own SOArchitecture approach my first implementation of Instancers wouldn’t create SOs, but simple classes. at runtime there is no real need for an SO. Not sure if this would be suitable for Atoms without an rework, though.

Issue Analytics

  • State:open
  • Created a year ago
  • Reactions:1
  • Comments:6

github_iconTop GitHub Comments

1reaction
toasterhead-mastercommented, Apr 27, 2023

Well, in such case I guess having an additional class wouldn’t hurt. Fortunately, I’ve implemented a unit testing infrastructure for UnityAtoms, so it will be easy to test it (I used the almighty powers of Reflection to make unit testing easy with unity atoms).

0reactions
soraphiscommented, Apr 29, 2023

I personally would be totally fine with having the instancers just behave like the atom instance. Like you did. Especially if it’s the easier approach.

For Ions I went full interfaces. I have PureIons (which are just classes), IonComponents (which are MonoBehaviours) and IonSOs (ScriptableObject) which all implement the same interfaces.

a IonReference is basically just a fancy InterfaceHelper that allows putting anything that implements that interface.

Unity 2022+ definitely supports generics, to a pretty far extend just not for SerializedReferences and Assets.

Read more comments on GitHub >

github_iconTop Results From Across the Web

What is garbage collection (GC) in programming?
Learn about garbage collection, the process programming languages use to free up memory space allocated to objects no longer needed by the program....
Read more >
How to choose the best Java garbage collector
In the next sections, we'll use these application requirements to discuss and compare the following garbage collectors:.
Read more >
Garbage Collection in Java
The main objective of Garbage Collector is to free heap memory by destroying unreachable objects. The garbage collector is the best example of ......
Read more >
Why do languages such as C and C++ not have garbage ...
Garbage collection requires data structures for tracking allocations and/or reference counting. These create overhead in memory, performance ...
Read more >
A Garbage Can Model of Organizational Choice
on the basis of a variety of inconsistent and ill-defined preferences. It can be described better as a loose collection of ideas than...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found