How does [Serialize Field] (and public) affect memory?

I’m trying to create a conversation system.
I’m trying to make it using string

When I write a string to an object using the [SerializeField] attribute or public quantifier, is this string in memory?

I’m not sure how this behavior will affect memory.

I am currently using a translator. Please understand that there are awkward parts.

Anything that you declare is basically memory :

public int health;
public static int damage;
private Vector3 offset;
// etc...

Making something public means that it can be used from other scripts(also shows in inspector), making something private means that no other script can get or read that value(does not show in inspector), and making a private declaration a [Serialized Field] just means that you can see it in inspector.

The only time something gets made in the Heap(random access memory), is when you do something like this :

public void ShootBullet()
{
    Vector3 newPos = transform.position + offset;
}

As you are now declaring something within runtime(basically), so therefor it is not in the Stack(memory).

For a better explanation on Stack vs Heap, there are plenty of youTube videos that go over this subject in great detail. But to sum it up, Garbage Collection is your enemy, and it is what constantly tries to keep the Heap clean, using up performance.

  • Also recommend watching youTube videos, by searching “Unity performance”. :)