Why is my instance removed by Unity?

Is it possible that Unity destroys instances if a application is not active for a while?

I have a static instance of my class GameManager which allows me to access it by any other script in my scene.

I create it on awake if the instance is still null.

It works perfect, but when I test the application I notice that this instance is sometimes destroyed.
I can replicate by running the application in Unity (Personal) on windows.

  1. I run the application
  2. Deselect Unity, ie Open explorer or something else.
  3. Wait a few minutes
  4. Select Unity again.

When I wait 1 or 2 minutes, nothing happens and I can continue.
If I wait longer I get errors when I try to access the GameManager instance when I returned to the application.

There is no line anywhere in my code that destroys the instance so it must be Unity that is destroying it.

You must be wrong. Find all Destroy and DestroyImediate lines and comment them out. Otherwise, check if the references to game manager are cleared.